Challenge

Project 1 - Parsing NASA thermodynamic data

% Nasa parsing challenge main code

clear all
close all
clc

f1 = fopen('THERMO.dat','r');
fgetl(f1);
global_temp = fgetl(f1);
A = strsplit (global_temp,' ');
global_min_temp = str2num (A{2});
global_med_temp = str2num (A{3});
global_max_temp = str2num(A{4});

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

% Skipping the next three comments.
for i = 3:5
comments = fgetl(f1);
end

% Getting the co-effs of species
for i = 1:53
%Extracting line 1 and name of the species
line1 = fgetl(f1);
name = strtok (line1);

% Getting higher and lower temp coeffs

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

A = strfind(line2,'E');
B = strfind(line3,'E');
C = strfind(line4,'E');

%Extracting Higher temp coeffs
a1 = str2num(line2(1:A(1)+3));
a2 = str2num(line2(A(1)+4:A(2)+3));
a3 = str2num(line2(A(2)+4:A(3)+3));
a4 = str2num(line2(A(3)+4:A(4)+3));
a5 = str2num(line2(A(4)+4:A(5)+3));
a6 = str2num(line3(1:B(1)+3));
a7 = str2num(line3(B(1)+4:B(2)+3));

%Extracting Lower temp coeffs
b1 = str2num(line3(B(2)+4:B(3)+3));
b2 = str2num(line3(B(3)+4:B(4)+3));
b3 = str2num(line3(B(4)+4:B(5)+3));
b4 = str2num(line4(1:C(1)+3));
b5 = str2num(line4(C(1)+4:C(2)+3));
b6 = str2num(line4(C(2)+4:C(3)+3));
b7 = str2num(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,a6,b1,b2,b3,b4,b5,b6,T,R,global_med_temp);

%entropy calculation
s = entropy_calc(a1,a2,a3,a4,a5,a7,b1,b2,b3,b4,b5,b7,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

% Logic behind the plot

1) At first i defined maximum, medium and minumum temerature, After that i converted string to number form

2)Then i created a for loop for all the species

3)Then i form different function for specefic heat,enthalpy,entropy,molecular weight,plotting and save them all in different script and saved them in the same folder

4) After that i took seven high temperature and seven low temperature and converted them from string to number

5) After that i putted those different value of temperature in various formulas and function,

6) Then i plotted the graph for various species, i have submitted plots for co2,N,o2, but you can find all the plots if you run the program

7) I have not put the function code in the main program,you can check them below

8) Please run the main program after downlaoding the function and saving them in the same folder.

% Error faced

1) At first i tried to run the program by puting all the function in one main script but it was not looking good and was not that understandable

2)Error faced due to various spelling and wrong parentheses

3)Error faced due to putting incorrect command

4)Error faced due to not saving the function in the same folder

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.