Project 1 - Parsing NASA thermodynamic data
main program
clear all
close all
clc
% Make directory
mkdir 'C:UserAdminDesktopNASA File Parsing'
% REAding DAta file -NASA Thermodynamic
% Open a file & 'r' open the file for reaading
f1=fopen('THERMO.dat','r')
gt=fgetl(f1);
f1 = fopen('THERMO.dat', 'r');
fgetl(f1);
tline = fgetl(f1);
A= strsplit(tline);
Global low temp = stradouble(A{2});
Global mid temp = str2double(A{3});
Global high_temp= str2double (A{4});
%Lines
for i = 3:5
g =fget1(f1);
end
%temp
for j = 1:53
species= fgetl(f1);
t=strfind(species,*) ;
%local temp
species (52-3:52+3) ;
T1 = species (52-3: t(1)+3);
T11 :=str2double (T1);
species(t(1)+6:62+3);
Th = species (t(1)+6:t(2)+3);
Thi
str2double(Th) ;
species(t(2)+6:72+3);
Tm = species (t(2)+6:t(3)+3);
TmI
str2double(Tm) ;
sp name= species (1:6);
% co-efficients1
coeff line 1= fgetl(f1);
A11= strfind(coeff line 1,'E' );
coeff line 1(1:12+3) ;
al = coeff line 1(1:A11 (1)+3) ;
C1= str2double(a1);
a2 = coeff line 1(A11(1) +4:A11(2)+3) ;
c2 = str2double(a2) ;
a3 = coeff line 1(A11(2) +4:A11(3)+3) ;
C3 = str2double (a3) ;
a4 = coeff line 1(A11(3) +4:A11(4)+3) ;
C4 = str2double(a4) ;
a5 = coeff_line_ 1 (A11(4) +4:A11 (5)+3);
c5 = stradouble(a5);
% Co-efficients 2
coeff_line_2=fgetl(f1);
A12 = strfind(coeff line 2,'E');
coeff line 2 (1:12+3) ;
a6 = coeff line 2 (1:A12(1)+3) ;
c6 = str2double(a6);
a7 = coeff line 1(A12(1) +4:A11(2)+3);
C7 = str2double(a7) ;
a8 = coeff line 1(A12(2)+4:A11(3) +3);
c8 = str2double (a8);
a9 = coeff line 1(A12(3) +4:A11(4)+3) ;
c9 = str2double(a9);
a10 = coeff line 1(A12(4) +4:A11 (5)+3);
C10 = str2double(a10) ;
% co-effecient 3
43
coeff line 3 = fgetl(f1);
A13 = strfind (coeff line 3,'E');
coeff line_3 (1:12+3) ;
a11 = coeff line 2 (1:A13(1)+3) ;
C11 = str2double (a11);
a12 = coeff line 1(A13(1) +4:A11(2)+3) ;
C12 = str2double (a12);
a13 = coeff line 1(A13(2)+4:A11(3)+3) ;
c13 = str2double(a13);
a14 = coeff line 1(A13(2)+4:A11(4)+3) ;
C14 = str2double (a14) ;
T= linspace(T11,Th1,100);
R= 8.314;
[Cp,H, S]= inputs (T, R, Tm1, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, C11,c12,c13,c14);
mkdir('C: \Users\hp\Documents \MATLAB \ASSIGNMENT \NASA File parsing\species’,sp_name)
%plotting
figure(1)
plot(T,Cp,'Linewidth' , 3, 'Color', 'b');
×label ('Temp ' );
label('Specific Heat’);
title(sp_name) ;
figure(2)
plot (T,H, 'Linewidth' ,3, 'Color', 'b');
xlabel('Temp");
label(' Entropy');
title(sp_name) ;
figure(3)plot (T,S,"Linewidth', 3,’color’, ’b’);
xlabel (' Temp ');
ylabel('Enthalpy')
title(sp_name) ;
program = (['C: \users\hp\Documents \MATLAB \ASSIGNMENT\NASAFileparsing\Species\, sp name ]) ;
cd (program)
A
saveas(1,
"Specific Heat. jpg' )
saveas(2,
'Entropy. jpg" )
saveas(3,
'Enthalpy. jpg" )
cd('C: \users \hp\Documents \MATLAB \ASSIGNMENT \NASA File parsing' )
molecular weight_calculation
= molecular weight (sp_name)
end
Fclose(f1)