Project

NASA File parsing

clear all
close all
clc
count=1;
j=1; 
k=1;
l=1;
fid=fopen(\'nasa.txt\',\'r\');
for j=1:5
fgetl(fid);
end
b=input(\'name of the specie\',\'s\');
for i=1:length(b)
    if(b(i)==\'C\')
        m(l)=12;
        l=l+1;
    elseif(b(i)==\'H\')
        m(l)=1;
        l=l+1;
    elseif(b(i)==\'O\')
        m(l)=16;
        l=l+1;
    elseif(b(i)~=\' \')
        c=str2double(b(i)); 
        t=c*(m(l-1));
        m(i)=t-m(l-1);
        l=l+1;
    end
end
molecularweight=sum(m)
while ~feof(fid)
st= fgetl(fid);
if(~isempty(strfind(st,b))&&count<2)
    coef=fgetl(fid);
    coef1=fgetl(fid);
    coef2=fgetl(fid);
    A=strfind(coef,\'E\');
    B=strfind(coef1,\'E\');
    C=strfind(coef2,\'E\');
    j=1;
    for i=1:length(A)
    a(i)=str2double(coef(j:A(i)+3));
    if str2double(coef(A(i)+4))==(\' \')
        j=A(i)+5;
    else
    j=A(i)+4;
    end
    end
    i=i+1;
    j=1;
     for k=1:length(B)
    a(i)=str2double(coef1(j:B(k)+3));
    if str2double(coef1(B(k)+4))==(\' \')
        j=B(k)+5;
    else
    j=B(k)+4;
    end
    i=i+1;
     end
    j=1;
    for k=1:length(C)
    a(i)=str2double(coef2(j:B(k)+3));
    if str2double(coef2(B(k)+4))==(\' \')
        j=B(k)+5;
    else
    j=B(k)+4;
    end
    i=i+1;
    end
    t=linspace(200,3500,50);
    for i=1:length(t)
        if t(i)<1000
            CP(i)=a(1)+a(2)*t(i)+a(3)*(t(i)^2)+a(4)*(t(i)^3)+a(5)*(t(i)^4);
            H(i)=8.314*t(i)*(a(1)+a(2)*t(i)/2+a(3)*(t(i)^2)/3+a(4)*(t(i)^3)/4+a(5)*(t(i)^4)/5+a(6)/t(i));
            S(i)=8.314*(a(1)*log(t(i))+a(2)*t(i)+a(3)*(t(i)^2)/2+a(4)*(t(i)^3)/3+a(5)*(t(i)^4)/4+a(7));
        else
              CP(i)=a(8)+a(9)*t(i)+a(10)*(t(i)^2)+a(11)*(t(i)^3)+a(12)*(t(i)^4);
              H(i)=8.314*t(i)*(a(8)+a(9)*t(i)/2+a(10)*(t(i)^2)/3+a(11)*(t(i)^3)/4+a(12)*(t(i)^4)/5+a(13)/t(i));
              S(i)=8.314*(a(8)*log(t(i))+a(9)*t(i)+a(10)*(t(i)^2)/2+a(11)*(t(i)^3)/3+a(12)*(t(i)^4)/4+a(14));
        end
    end
    figure(1)
    plot(t,CP,\'r-\')
    xlabel(\'temperature\')
    ylabel(\'Cp\')
    figure(2)
    plot(t,H,\'b-\')
    xlabel(\'temaperature\')
    ylabel(\'H\')
    figure(3)
    plot(t,S,\'g-\')
    xlabel(\'temaperature\')
    ylabel(\'S\')
    count=count+1;
end
end
for i=1:3
savefig(figure(i),fullfile(\'C://Users//KUMAR APURVA//Desktop//matlab\',[\'figure\' num2str(i) \'.fig\']))
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.