Project 1 - Parsing NASA thermodynamic data
clear all
close all
clc
f1 = fopen('thermo.dat','r');
first_line = fget1(f1);
%R is the universal gas constant j/(mol-k)
R = 8.314;
temp = fget1(f1);
% reading text from a header file
%reading the global temperature from the next line
A = strsplit(temp,'');
% cell array is generated 1x4 cell array
glob_lowtemp = str2num(A{2});
glob_midtemp = str2num(A{3});
glob_hightemp = str2num(A{4});
% temperature range
temperature = linspace (glob_lowtemp, glob_hightemp,1000);
% skipping the three comment lines
for j = 1.3;
k = fget1(f1);
end
% running for loop fopr 53 time as there are 53 species
for i = 1:53;
% parsing of the species block
tline = fget1(f1);
S = strsplit(tline,'');
species_name = S{1};
% Extracting the coefficients from first line
line2 = fget1(f1);
x = findstr(line2,'E');
% finding the 5 coefficient
x1 = line2(1:x(1)+3);
x1 = str2num(x1);
x2 = line2(1:x(1)+4:x(2)+3);
x2 = str2num(x2);
x3 = line2(1:x(2)+4:x(3)+3);
x3 = str2num(x3);
x4 = line2(1:x(3)+4:x(4)+3);
x4 = str2num(x4);
x5 = line2(1:x(4)+4:x(5)+3);
x5 = str2num(x5);
% line3 5coefficients
line3 = fget1(f1);
x = findstr(line3,'E');
x6 = line3(1:x(1)+3);
x6 = str2num(x6);
x7 = line3(1:x(1)+4:x(2)+3);
x7 = str2num(x7);
x8 = line3(1:x(2)+4:x(3)+3);
x8 = str2num(x8);
x9 = line3(1:x(3)+4:x(4)+3);
x9= str2num(x9);
x10 = line3(1:x(4)+4:x(5)+3);
x10 = str2num(x10);
% line4 4coefficients
line4 = fget1(f1);
x = findstr(line4,'E');
x11 = line3(1:x(1)+3);
x11 = str2num(x11);
x12= line3(1:x(1)+4:x(2)+3);
x12 = str2num(x12);
x13 = line3(1:x(2)+4:x(3)+3);
x13 = str2num(x13);
x14 = line3(1:x(3)+4:x(4)+3);
x14= str2num(x14);