Project

NASA THERMO PROJECT

clc 
clear all
close all
% make sure the file is below path
f1 = fopen(\'E:\\Matlab_Project\\NASATHERMO.txt\',\'r\');
%rading of DATA
fgetl(f1);
A = fgetl(f1);
A = strsplit(A,\' \');
for i=1:length(A)
global_temp(i)= str2double(A{i});
end
for k=3:5
    comment=fgetl(f1);
end
for i=1:4:216
main = fgetl(f1);
main = strsplit(main,\' \');
for k=1:length(main)
Data1(i,k) = string(main(k));
end 
for j=i+1:i+3
temp = fgetl(f1);
flag = strfind(temp,\'E\');
for k=1:length(flag)
flag1 = temp(flag(k)-11:flag(k)+3);
Data2(j,k)  = str2double(flag1);
end
end
end
for i = 1:length(Data1)
Element(i,1)= Data1(i,1);
 end 
Element = rmmissing(Element);
% Convert 3*5 array into 1*14
for i = 2:4:length(Data2)
    c = (i+2)/4;
for k=1:5
    Data2(c,k) = Data2(i,k);
for k=6:10
    Data2(c,k) = Data2(i+1,k-5);
    for k= 11:14
    Data2(c,k) = Data2(i+2,k-10);
    end
end
end
end
for i=54:length(Data2)
for k=1:14
    Data2(i,k) = [0];
end
end
R = 8.314;
opt = input(\' Is the temperature as per Default global temp? Y/N\',\'s\')
opt = upper(opt);
if (opt == \'Y\')
T= linspace(global_temp(2),global_temp(4),100);
else if(opt == \'N\')
str = input(\'if manual overide, Enter The temperature range with a space\',\'s\');
T= linspace(str(1),str(2),100);
else 
disp(\'Enter the correct option\')
end
end
% Calculation of Coefficients.
for i =1:length(Element)
for j=1:length(T)
if (T(j)<1000)
Cp(i,j) = R*(Data2(i,1)+(Data2(i,2)*T(j))+(Data2(i,3)*(T(j)^2)) + (Data2(i,4)*(T(j)^3))+(Data2(i,5)*(T(j)^4)));
H(i,j) = R*((Data2(i,1)*T(j))+(Data2(i,2)/2)+(Data2(i,3)*T(j)/3) + (Data2(i,4)*(T(j)^2)/4)+(Data2(i,5)*(T(j)^3)/5)+Data2(i,5));
S(i,j) = Data2(i,1)*log(T(j))+(Data2(i,2)*T(j))+(Data2(i,3)*(T(j)^2)/2) + (Data2(i,4)*(T(j)^3)/3)+(Data2(i,5)*(T(j)^4)/4) + Data2(i,7);
else 
Cp(i,j) = R*(Data2(i,8)+(Data2(i,9)*T(j))+(Data2(i,10)*(T(j)^2)) + (Data2(i,11)*(T(j)^3))+(Data2(i,12)*(T(j)^4)));
H(i,j) = R*((Data2(i,8)*T(j))+(Data2(i,9)/2)+(Data2(i,10)*T(j)/3) + (Data2(i,11)*(T(j)^2)/4)+(Data2(i,12)*(T(j)^3)/5)+Data2(i,13));
S(i,j) = Data2(i,8)*log(T(j))+(Data2(i,9)*T(j))+(Data2(i,10)*(T(j)^2)/2) + (Data2(i,11)*(T(j)^3)/3)+(Data2(i,12)*(T(j)^4)/4) + Data2(i,14);
end
end
end
%Calculate Molecular Weight%
disp(\'enter element such that CH3OH as CHHHOH\')
substance = input(\'Enter the element as shown in example\',\'s\')
substance = upper(substance)
[count] = zeros(1,6)
for i = 1:length(substance)
    if substance(i) == \'C\'
        count(1) = count(1)+1
    else if substance(i) == \'H\';
            count(2) = count(2)+1;
        else if substance(i) == \'O\';
            count(3) = count(3)+1 ;
            else if substance(i) == \'N\';
            count(4) = count(4)+1;
            else if substance(i) == \'S\';
            count(5) = count(5)+1;
     else if substance(i) == \'AR\';
            count(6) = count(6)+1;
    end
    end
    end
    end
    end 
    end
end
Mol_wt = (count(1)*12)+(count(2)*1)+(count(3)*16)+(count(4)*14)+(count(5)*32)+(count(6)*40)
fprintf(\'The Molecular weight of %s is %f\',substance,Mol_wt)
% Printing of Plots %
for i=1:length(Element)
figure(i)
subplot(3,1,1)
plot (Cp(i,:),T,\'color\',\'b\')
title(\'Plot of specific heat versus Temperature\')
xlabel(\'specific heat\'); ylabel(\'T\') 
subplot(3,1,2)
plot (H(i,:),T,\'color\',\'b\')
title(\'Plot of enthalpy versus Temperature\')
xlabel(\'enthalpy\'); ylabel(\'T\') 
subplot(3,1,3)
plot (S(i,:),T,\'color\',\'b\')
title(\'Plot of Entropy versus Temperature\')
xlabel(\'Entropy\'); ylabel(\'T\') 
 %Printing of results into Folders%
condir = char(Element(i))
filename1 = fullfile(\'E:\\\',\'Matlab_Project\',condir)
mkdir (filename1)
filename2 = fullfile(filename1,condir)
saveas(figure(i),filename2,\'jpg\')
end

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.