Project

Parsing NASA Thermodynamic Data

In this project i have written a code that reads line by line of the given data file and searches the special character in each line simultaneously,in this case it\'s \'E+\'or \'E-\',if its found then a loop is executed to collect the 14 co-efficients of the material.These co-efficients are then send to graph.m file for calculation of Cp,H,S and plotting of graph.There is an inf loop ruuning for reading each line of data and simultaneously searching foe keyword \'END\' in the line if it\'s found then if statement closes the data file thus stopping the loop.Given below is the code;

close all 
clear all
clc


f1 = fopen('nasa-data.txt');
j = 1;
global ct tt
ct = 1;
%s = fgetl(f1);


for i = 1:inf
    s = fgetl(f1);
    qw = findstr(s,'     ');
    if length(qw) ~= 0
        if qw(1) <=8
             tt = s(1:6)
        end
    end
    if s(1:3) == 'END'
        fclose(f1)
        
    end
    
    a = findstr(s,'E+');
    b = findstr(s,'E-');
    x = 1;
    
    q1 = size(a);
    q2 = size(b);

    q = q1(1) + q2(1);

        if or(q == 1, q == 2)              %condition for reading line
            f = findstr(s,'E');
            fs = size(f);                  % fs = 1x2 , f = 1x4 or 1x5

            if j == 15
                j= 1;
               [Y1,Y2,Y3] =  graph(c);
                ct = ct +1;
                
            end


            for i = 1: length(f)

                y = f(i) + 3;
                
                c(j) = str2num(s(x:y));
                x = 1+y;

                j = j+1;

            end


        end
    
end
fclose(f1)
    
    
   

code for function graph.m:

function  [C_P,H,S] = plot_fun(c)
  
   syms t
   global ct
   global tt
    r = 8.13;
    C_P = (c(1) + c(2)*t + c(3)*t^2 + c(4)*t^3 + c(5)*t^4)*r ;
   
    H = ( c(1) + (c(2)*t)/2 + (c(3)*t^2)/3 + (c(4)*t^3)/4 + (c(5)*t^4)/5 + c(6)*t^5 )*r*t ;
    
   S = ( c(1)*log(t) + c(2)*t + (c(3)*t^2)/2 + (c(4)*t^3)/3 + (c(5)*t^4)/4 + c(7))*r ;
    
    hh = figure(ct)
   
    subplot(3,1,1)
    ezplot(C_P,[100,1000])
    xlabel('Temperature')
    ylabel('Cp')
     title(tt)
    subplot(3,1,2)
    ezplot(H,[100,1000])
     xlabel('Temperature')
     ylabel('H')
     title(tt)    
    subplot(3,1,3)
    ezplot(S,[100,1000])
     xlabel('Temperature')
    ylabel('S')
     title(tt)
     
     mkdir('C:\Users\yasham raj\Desktop\New folder (4)\',num2str(ct))  
     
     saveas(hh,['C:\Users\yasham raj\Desktop\New folder (4)\',num2str(ct),'\figure_',tt,'.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.