Project 1 - Parsing NASA thermodynamic data
clear all
close all
clc
f1 = fopen('THERMO.dat','r');
line_1 = fgetl(f1);
line_2 = fgetl(f1);
A = strsplit(line_2, ' ');
global_low_temp = str2double(A{2});
global_mid_temp = str2double(A{3});
global_high_temp = str2double(A{4});
for i = 3:5
data = fgetl(f1);
end
for i = 1:53
line_3 = fgetl(f1);
line3_split = strsplit(line_3, ' ');
species_name = line3_split{1};
splits = strfind(line_3, 'G');
temp_values=line_3(splits+4:length(line_3));
splits_temp=strsplit(temp_values,' ');
Hp_low = str2double(splits_temp{1});
Hp_mid = str2double(splits_temp{2});
Hp_high = str2double(splits_temp{3});
line_4 = fgetl(f1);
b = strfind(line_4,'E');
a1 = str2double(line_4(1:b(1)+3));
a2 = str2double(line_4(b(1)+4:b(2)+3));
a3 = str2double(line_4(b(2)+4:b(3)+3));
a4 = str2double(line_4(b(3)+4:b(4)+3));
a5 = str2double(line_4(b(4)+4:b(5)+3));
line_5 = fgetl(f1);
b = strfind(line_5,'E');
a6 = str2double(line_5(1:b(1)+3));
a7 = str2double(line_5(b(1)+4:b(2)+3));
a8 = str2double(line_5(b(2)+4:b(3)+3));
a9 = str2double(line_5(b(3)+4:b(4)+3));
a10 = str2double(line_5(b(4)+4:b(5)+3));
line_6 = fgetl(f1);
b = strfind(line_6,'E');
a11 = str2double(line_6(1:b(1)+3));
a12 = str2double(line_6(b(1)+4:b(2)+3));
a13 = str2double(line_6(b(2)+4:b(3)+3));
a14 = str2double(line_6(b(3)+4:b(4)+3));
T = linspace(Hp_low,Hp_high,1000);
R = 8.314;
cp = R*specific_heat(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,Hp_mid,Hp_low,Hp_high,T);
S = R*entropy(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,Hp_mid,Hp_low,Hp_high,T);
H = R*enthalpy(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,Hp_mid,Hp_low,Hp_high,T);
mkdir(['E:\Skill-Lync\Matlab\ff\',species_name]);
cd(['E:\Skill-Lync\Matlab\ff\',species_name]);
figure(1)
plot(T,cp)
xlabel('Temp')
ylabel('Specific Heat')
title('specific Heat vs Temp')
image=(getframe(gcf));
imwrite(image.cdata,'specific_heat vs temperature.png')
figure(2)
plot(T,H)
xlabel('Temp')
ylabel('Enthalpy')
title('Enthalpy vs Temp')
image=(getframe(gcf));
imwrite(image.cdata,'Enthalpy vs temperature.png')
figure(3)
plot(T,S)
xlabel('Temp')
ylabel('Entropy')
title('Entropy vs Temp')
image=(getframe(gcf));
imwrite(image.cdata,'Entropy vs temperature.png')
cd(['E:\Skill-Lync\Matlab\ff\',species_name]);
M = molecular_weight(species_name);
P = sprintf('%s Molecular Weight = %f \n',species_name,M);
disp(P)
end