Project 1 - Parsing NASA thermodynamic data
clear all
close all
clc
% NASA Parsing
fileID = fopen('THERMO.dat','r');
main_header = fgetl(fileID);
global_temp_header = fgetl(fileID);
global_temp = strsplit(global_temp_header);
% Calculating global temperature values
global_low_temp = str2double(global_temp{2});
global_mid_temp = str2double(global_temp{3});
global_high_temp = str2double(global_temp{4});
for i=1:3
skip_lines = fgetl(fileID);
end
for i=1:53
species_header = strsplit(fgetl(fileID));
% Extract species name
species_name = species_header{1};
% Extract species local temperature values
local_low_temp = str2double(species_header{end-3});
local_mid_temp = str2double(species_header{end-1});
local_high_temp = str2double(species_header{end-2});
T=linspace(local_low_temp,local_high_temp,500);
L1=fgetl(fileID);
P1=findstr(L1,'E');
a1=str2double(L1(1:P1(1)+3));
a2=str2double(L1(P1(1)+4:P1(2)+3));
a3=str2double(L1(P1(2)+4:P1(3)+3));
a4=str2double(L1(P1(3)+4:P1(4)+3));
a5=str2double(L1(P1(4)+4:P1(5)+3));
L2=fgetl(fileID);
P2=findstr(L2,'E');
a6=str2double(L2(1:P2(1)+3));
a7=str2double(L2(P2(1)+4:P2(2)+3));
a8=str2double(L2(P2(2)+4:P2(3)+3));
a9=str2double(L2(P2(3)+4:P2(4)+3));
a10=str2double(L2(P2(4)+4:P2(5)+3));
L3=fgetl(fileID);
P3=findstr(L3,'E');
a11=str2double(L3(1:P3(1)+3));
a12=str2double(L3(P3(1)+4:P3(2)+3));
a13=str2double(L3(P3(2)+4:P3(3)+3));
a14=str2double(L3(P3(3)+4:P3(4)+3));
molecularweight=m_wt(species_name);
sprintf('Molecular weight of %s=%d',species_name,molecularweight)
[Cp,H,S]=NASAPROPERTIES(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,T,local_mid_temp);
t=sprintf('%s', species_name);
mkdir(t)
cd(t)
figure(1)
plot(Cp,T)
xlabel('Specific_heat')
ylabel('temperature')
saveas(1,'Cp.jpg')
figure(2)
plot(H,T)
xlabel('Enthalpy')
ylabel('temperature')
saveas(2,'H.jpg')
figure(3)
plot(S,T)
xlabel('Entropy')
ylabel('temperature')
saveas(3,'S.jpg')
cd ..
end