Challenge

Project 1 - Parsing NASA thermodynamic data

clear all
close all
clc
%opening of NASA's thermodynamic data
f1 = fopen('THERMO.dat2','r');
first_line = fgetl(f1);

%obtaining of global max,min and medium temperature
global_temp = fgetl(f1);
temp_range = strsplit(global_temp,' ');
global_min_temp = str2double(temp_range{2});
global_med_temp = str2double(temp_range{3});
global_max_temp = str2double(temp_range{4});

%Range of temperature
T = linspace(global_min_temp,global_max_temp,400);
R = 8.314;

%skipping the next three comments in the file
for i = 3:5
    comments = fgetl(f1);
end

%getting the coeffs of species 

for i = 1:53
    line1 = fgetl(f1);
    name = strtok(line1);

    line2 = fgetl(f1);
    line3 = fgetl(f1);
    line4 = fgetl(f1);

    A = strfind(line2,'E');
    B = strfind(line3,'E');
    C = strfind(line3,'E');
   
    %extracting higher temp coeffs

    a1 = str2double(line2(1:A(1)+3));
    a2 = str2double(line2(A(1)+4:A(2)+3));
    a3 = str2double(line2(A(2)+4:A(3)+3));
    a4 = str2double(line2(A(3)+4:A(4)+3));
    a5 = str2double(line2(A(4)+4:A(5)+3));
    a6 = str2double(line3(1:B(1)+3));
    a7 = str2double(line3(B(1)+4:B(2)+3));

    %extracting lower temp coeffs

    b1 = str2double(line3(B(2)+4:B(3)+3));
    b2 = str2double(line3(B(3)+4:B(4)+3));
    b3 = str2double(line3(B(4)+4:B(5)+3));
    b4 = str2double(line4(1:C(1)+3));
    b5 = str2double(line4(C(1)+4:C(2)+3));
    b6 = str2double(line4(C(2)+4:C(3)+3));
    b7 = str2double(line4(C(3)+4:C(4)+3));

%specific heat calculation
   
    cp = specificheat(a1,a2,a3,a4,a5,b1,b2,b3,b4,b5,T,R,global_med_temp);
% enthalpy calculation
    h = enthalpy(a1,a2,a3,a4,a5,b1,b2,b3,b4,b5,T,R,global_med_temp);
%entropy calculation
    s = entropy(a1,a2,a3,a4,a5,b1,b2,b3,b4,b5,T,R,global_med_temp);
% calculating molecular weight of species 
    Molecular_wt(i) = molecular_weight(name);
%creating individual folder for each species and plotting
    plotting(cp,h,s,T,name)

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.