%PROGRAM TO PRASE NASA'S THERMODYNAMIC DATA
clear all %clear the workspace
close all %clear all the figure window
clc %clear the command window
%OPENING AND READING THE GIVEN FILE
file = fopen('THERMO.dat','r'); %Opening the THERMO.dat file to read.Here file is a scalar matlab integer,called file identifier
%Heading
line1 = fgetl(file); %Assigning the heading to line1.fget1() returns the next line without newline characters
%Global temperature values
line2 = fgetl(file); %Assigning the global temperature values to line2.fget1() returns the next line without newline characters
%Next three lines are comments
des_1 = fgetl(file); %Assigning the next line to des_1.
des_2 = fgetl(file); %Assigning the next line to des_3.
des_3 = fgetl(file); %Assigning the next line to des_3.
%Assigning the Global temperatures
A = strsplit(line2,' '); %spliting the line2 using space character as an delimiter
Global_low_temperature = str2num(A{2}); %Assigning the golbal low temperature from array A as a number
Global_mid_temperature = str2num(A{3}); %Assigning the golbal mid temperature from array A as a number
Global_high_temperature = str2num(A{4}); %Assigning the golbal high temperature from array A as a number
%SPECIES INFORMATION
for i=1:53 %Running a for loop for every molecule
species= fgetl(file) %Assigning the molecule data's 1st line from the file to species
species_name = species(1:6) %Assigning the species name from the 1st 6 elements of species array
%Local temperature values for each molecules
B = strsplit(species,' '); %spliting the species using space character as an delimiter
Local_low_temperature = str2num(B{end-3}); %Assigning the local low temperature from array B as a number
Local_high_temperature = str2num(B{end-2}); %Assigning the local high temperature from array B as a number
Local_mid_temperature = str2num(B{end-1}); %Assigning the local mid temperature from array B as a number
Line_1 = fgetl(file); %Assigning the molecule data's 2nd line from the file to Line_1
L1 = strfind(Line_1,'E'); %Finding the 'E' letter in Line_1 to differentiate the data
%Assigning the High temperature coefficients
c1 = str2num(Line_1(1:(L1(1)+3)));
c2 = str2num(Line_1((L1(1)+4):(L1(2)+3)));
c3 = str2num(Line_1((L1(2)+4):(L1(3)+3)));
c4 = str2num(Line_1((L1(3)+4):(L1(4)+3)));
c5 = str2num(Line_1((L1(4)+4):(L1(5)+3)));
Line_2 = fgetl(file); %Assigning the molecule data's 3rd line from the file to Line_2
L2 = strfind(Line_2,'E'); %Finding the 'E' letter in Line_2 to differentiate the data
%Assigning the High temperature coefficients
c6 = str2num(Line_2(1:(L2(1)+3)));
c7 = str2num(Line_2((L2(1)+4):(L2(2)+3)));
%Assigning the Low temperature coefficients
c8 = str2num(Line_2((L2(2)+4):(L2(3)+3)));
c9 = str2num(Line_2((L2(3)+4):(L2(4)+3)));
c10 = str2num(Line_2((L2(4)+4):(L2(5)+3)));
Line_3 = fgetl(file); %Assigning the molecule data's 4th line from the file to Line_3
L3 = strfind(Line_3,'E'); %Finding the 'E' letter in Line_3 to differentiate the data
%Assigning the Low temperature coefficients
c11 = str2num(Line_3(1:(L3(1)+3)));
c12 = str2num(Line_3((L3(1)+4):(L3(2)+3)));
c13 = str2num(Line_3((L3(2)+4):(L3(3)+3)));
c14 = str2num(Line_3((L3(3)+4):(L3(4)+3)));
%Creating folder for each species
mkdir(['C:UsersUSEROneDriveDocumentsMATLABFILE PARSING OF NASA THERMODYNAMIC DATASpecies',species_name]);
%Temperature ranges assumed for calculation purpose
Temperature = linspace(Local_low_temperature,Local_high_temperature,100);
%Universal gas constant
R =8.314;
%CALCULATION OF PROPERTIES BASED ON THE LOWER AND UPPER TEMPERATURE
for j = 1:length(Temperature) %Running a for loop for every temperature values
%When the temperature is below the middle temperature
if Temperature(j)