Project 1 - Parsing NASA thermodynamic data
from the given the question
the given file is extracted from the given question by using the command
fopen(filename) =f1 and asigned to the f1
and the second line is extracted from the file as it is asigned to the temperature
temperature =fgetl(f1);
and this temperature ranges are asigned to the 'strsplit' this command help us to split the line into some parts with respect to the spaces provided in the line
and this splited lines are attached individual to the minimum and medium and maximum temperatures as using the command str2double /str2num can help us to extract the number from the cell array
as
global_min_temperature = str2double(temperature_range {2});
global_med_temperature = str2double(temperature_range {3});
global_max_temperature = str2double(temperature_range {4});
this temperature of maximum and minimum are divided into 400 parts by using the linspace command as it asignesd to the T
t= linspace(maximum temp,minimum temp,400);
to extract the comments from the file used thefor loop and extracted by the process
for i= 3:5
commets=fgetl(f1);
end
and to extract the molecular weights of the atoms we used the for loop
and to find the coeefficient of highrt temperatures and lower temperatures
we extracted the lin using the comand
strtok this command is used to find the line by using this command we find the value
name=strtok(line1);
line2=fgetl(f1);
line3=fgetl(f1);
line4=fgetl(f1);
later to find the constant from the line we use the command the 'strfind' this help us to idenfie the individual constant variable in the line as the form of the array
by using this data we find the coefficient of the higher temperature as A(1,2,3,4,5,6,7) and for same in lower coefficient temperature as B(1,2,3,4,5,6,7)
by using the command called 'str2double'
A1=str2double(line2(1:12+3));
A2=str2double(line2(a(1)+4:a(2)+3));
A3=str2double(line2(a(2)+4:a(3)+3));
A4=str2double(line2(a(2)+4:a(4)+3));
A5=str2double(line2(a(4)+4:a(5)+3));
A6=str2double(line3(1:12+3));
A7=str2double(line3(b(1)+4:b(2)+3));
%extracting the lower temperatures
B1=str2double(line3(b(2)+4:b(3)+3));
B2=str2double(line3(b(3)+4:b(4)+3));
B3=str2double(line3(b(4)+4:b(5)+3));
B4=str2double(line4(1:12+3));
B5=str2double(line4(b(1)+4:b(2)+3));
B6=str2double(line4(b(2)+4:b(3)+3));
B7=str2double(line4(b(3)+4:b(4)+3));
later all the constant variables are asigned with the specific heat ,entropy and enthaply
are as follow
CP=specific_heat(A1,A2,A3,A4,A5,B1,B2,B3,B4,B5,T,R,global_med_temperature);
H=enthalpy(A1,A2,A3,A4,A5,A6,B1,B2,B3,B4,B5,B6,T,R,global_med_temperature);
s=entropy(A1,A2,A3,A4,A5,A6,A7,B1,B2,B3,B4,B5,B6,B7,T,R,global_med_temperature);
to find the molecular weight od the atom we use the coomand as
molecular_weight(name)=molecular_weight(i);
plotting of the graphs was to find is
plotting (CP,H,s,T,name)
later by using the sub programming
by using the function command w find the value od the molecular weight
first we asigned as the
molecualr names are given as we taken from the data we got
as atoms=['H','C','O','N','R'];
we use the command as the fprintf to pront the molecular weight
as in the same way we use the frintf to print the name
ater used for loop with i command for their weight
and another for loop for the their name s
and later they are asigned with the if command as using the strcmp it help us to combine the two variable sinto the one as shown below
for i=1:length(name)
for j=1:length(atoms)
if strcmp(name(i),atoms(j))
MW=MW+atomic_weights(j);
position=j;
end
end
n=str2double(name(i));
if n>1
MW=MW+atomic_weights(position)*(n-1);
end
end
fprintf('%d',MW)
disp(' ')
layer ploted the graph for the temperature vs specific heat ,entropy and entholpy
as shown
figure(1)
plot(T,CP)
xlabel('temperature')
ylabel('specific heat')
figure(2)
plot(T,H)
xlabel('temperature')
ylabel('entropy')
figure(3)
plot(T,s)
xlabel('temperature')
ylabel('enthlapy')
cd(dir_name)
saveas(1,'cp vs t_png')
saveas(2,'h vs t_png')
saveas(3,'s vs t_png')
end
later from the given question i identifed the values for the specific heat ,entropy and enthlapy
as shown
function CP =specific_heat(A1,A2,A3,A4,A5,B1,B2,B3,B4,B5,T,R,global_med_temperature)
%temperature range is taken medium because we found out the lowest and
%highest temperatures
if T>global_med_temperature
%equation of entropy given in question
CP=R.*(A1+(A2.*T)+(A3.*T.^2)+(A4.*T.^3)+(A5.*T.^4));
else
CP = R.*(B1+(B2.*T)+(B3.*T.^2)+(B4.*T.^3)+(B5.*T.^4));
end if is used to find the higher coefficent value and the lower coefficent values for the given specific heat
function H=enthalpy(A1,A2,A3,A4,A5,A6,B1,B2,B3,B4,B5,B6,T,R,global_med_temperature)
%temperature range is taken medium because we found out the lowest and
%highest temperatures
if T>global_med_temperature
%equation of entropy given in question
H=R*(A1.*T+(A2.*T.^2)./2+(A3.*T.^3)./3+(A4.*T.^4)./4+(A5.*T.^4)./4+A6);
else
H=R*(B1.*T+(B2.*T.^2)./2+(B3.*T.^3)./3+(B4.*T.^4)./4+(B5.*T.^5)./4+B6);
end
function s=entropy(A1,A2,A3,A4,A5,A6,A7,B1,B2,B3,B4,B5,B6,B7,T,R,global_med_temperature)
%temperature range is taken medium because we found out the lowest and
%highest temperatures
if T<=global_med_temperature
%equation of entropy given in question
s=R*(A1+A2.*T+A3.*T.^2+A4.*T.^3+A5.*T.^4+A6.*T.^5+A7.*T.^7);
else
s=R*(B1+B2.*T+B3.*T.^2+B4.*T.^3+B5.*T.^4+B6.*T.^5+B7.*T.^7);
end
similary to the specific heat
and stored in the data as using the coomand as the 'dir '
error found
while doing the program unable to identify the molecular weight u
unable to the vector multiplication
unavle to open the file in the begin
unavle to solve the unregoinsied variablein the entropy
error correction
this concept i came to know that the from the class in the form of for loop
it was explained by the command promt for vector multiplication
itwas done becouse of saving the file in regularfloder
it was explained by the coomand pront for using the unrecogined variable
program is stored in the destop of my laptop using the THERMO.DAT

