Project

nasa thermodynamic data

here, written code reads the data line by line from the given file and searches the special character in each line simultaneously,in this case it\\\'s \\\'E+\\\'or \\\'E-\\\'. if it is found, the 14 co-efficients from the given data are collected and stored.These co-efficients are then send to graph.m file for calculation of Cp,H,S and plotting of graph.There is an infinite loop running for reading each line of data and simultaneously searching for 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(\'thermo30.dat.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)
    
    
   

function for calculating values of Cp,H,S and also plotting and storing the graphs

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\\new\\Desktop\\mat prgrms\\\',num2str(ct))  
     
     saveas(hh,[\'C:\\Users\\new\\Desktop\\mat prgrms\\\',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.