clear all
close all
clc
f1 = fopen(\'THERMO.dat\',\'r\')
v1 = fgetl(f1)
v2 = fgetl(f1)
A = strsplit(v2,\' \')
%global temperature
global_low_temp = str2num(A{2});
global_mid_temp = str2num(A{3});
global_high_temp = str2num(A{4});
for i = 1:3
M{i} = fgetl(f1);
end
for j = 1:inf
W = fgetl(f1);
B = strsplit(W,\' \');
Name = B(1);
if strcmp(Name,\'END\')
disp(\'End of File\');
fclose(f1)
break
end
L = findstr(W,\'.\');
p = W(L(1)-3:L(1)+23);
L_temp = strsplit(p,\' \');
L_temp_low = str2num(L_temp{1});
L_temp_high = str2num(L_temp{2});
L_temp_mid = str2num(L_temp{3});
X = fgetl(f1);
c = findstr(X,\'E\');
a{1} = X(1:c(1)+3);
a{2} = X(c(1)+4:c(2)+3);
a{3} = X(c(2)+4:c(3)+3);
a{4} = X(c(3)+4:c(4)+3);
a{5} = X(c(4)+4:c(5)+3);
Y = fgetl(f1);
c = findstr(Y,\'E\');
a{6} = Y(1:c(1)+3);
a{7} = Y(c(1)+4:c(2)+3);
a{8} = Y(c(2)+4:c(3)+3);
a{9} = Y(c(3)+4:c(4)+3);
a{10} = Y(c(4)+4:c(5)+3);
Z = fgetl(f1);
c = findstr(Z,\'E\');
a{11} = Z(1:c(1)+3);
a{12} = Z(c(1)+4:c(2)+3)
a{13} = Z(c(2)+4:c(3)+3);
a{14} = Z(c(3)+4:c(4)+3);
for k = 1:14
a{k} = str2num(a{k});
end
% The gas constant R is 8.314 J / mol
R = 8.314;
%calculationof cp
cp_low = R*a{8}+R*a{9}*L_temp_low+R*a{10}*L_temp_low^2+R*a{11}*L_temp_low^3+R*a{12}*L_temp_low^5;
cp_high = R*a{1}+R*a{2}*L_temp_high+R*a{3}*L_temp_high^2+R*a{4}*L_temp_high^3+R*a{5}*L_temp_high^5;
%calculation of H
H_low = R*L_temp_low*(a{8}+(a{9}*L_temp_low)/2+(a{10}*L_temp_low^2)/3+(a{11}*L_temp_low^3)/4+(a{12}*L_temp_low^4)/5+a{13}*L_temp_low);
H_high = R*L_temp_high*(a{1}+(a{2}*L_temp_high)/2+(a{3}*L_temp_high^2)/3+(a{4}*L_temp_high^3)/4+(a{5}*L_temp_high^4)/5+a{6}*L_temp_high);
%calculation of S
S_low = R*(a{8}*log(L_temp_low)+a{9}*L_temp_low+(a{10}*L_temp_low^2)/2+(a{11}*L_temp_low^3)/3+(a{12}*L_temp_low^4)/4+a{14});
S_high = R*(a{1}*log(L_temp_high)+a{2}*L_temp_high+(a{3}*L_temp_high^2)/2+(a{4}*L_temp_high^3)/3+(a{5}*L_temp_low^4)/4+a{7});
% Plotting
figure(1)
bar(L_temp_low,cp_low)
hold on
bar(L_temp_high,cp_high)
hold off
legend(\'Cp for High Temp\',\'Cp for Low temp\')
saveas(gcf,\'Cp.jpg\')
saveas(gcf,\'Cp.pdf\')
end