Challenge

Project 1 - Parsing NASA thermodynamic data

function W = Molecular_weight(species)

% Defining Atomic name of the species
atomic_name = ['H','C','O','N','Ar'];

% defining atomic masses of main species
atomic_weight =[1.008 12.011 15.999 14.007 39.948];

W=0; % Molecular weight starting range

for i=1:length(species) % loop runs to the length of the species
 for j=1:length(atomic_name) % loop runs to the length of the atomic names
     if strcmp(species(i), atomic_name(j)); % Function to compare 2 strings
         W=W+atomic_weight(j);
         position =  j;
     end
 end
 n=str2num(species); % Now we will find if there is more element in the species then incrementing the atomic weight of the species
 if n>1
     W=W + atomic_weight(position)*(n-1);
 end 
end
fprintf('Molecular Weight of %s : - ', species);
fprintf('%f',W);
disp(' ')
end

%Specific heat
function cp = specific_heat(a1,a2,a3,a4,a5,a8,a9,a10,a11,a12,T,R,global_mid_temp)

% calculating Specific heat for higher and lower Temperature

if (T <= global_mid_temp)
cp = R*(a8+(a9*T)+(a10*(T).^2)+(a11*(T).^3)+(a12*(T).^4));
else
cp =  R*(a1+(a2*T)+(a3*(T).^2)+(a4*(T).^3)+(a5*(T).^4));
end
end

%Entropy
function s = Entropy(a1,a2,a3,a4,a5,a7,a8,a9,a10,a11,a12,a14,T,R,global_mid_temp)

% calculating Entropy For higher and lower Temperature

if (T <= global_mid_temp)
    s = R*(a8.*log(T)+(a9*T)+((a10*(T).^2)/2)+((a11*(T).^3)/3)+((a12*(T).^4)/4)+a14);
else
    s = R*(a1.*log(T)+(a2*T)+((a3*(T).^2)/2)+((a4*(T).^3)/3)+((a5*(T).^4)/4)+a7);
end
end

%Enthalpy
function H = Enthalpy(a1,a2,a3,a4,a5,a6,a8,a9,a10,a11,a12,a13,T,R,global_mid_temp)

% calculating Enthalpy for higher and lower temperature

if (T <=global_mid_temp)

    H = R*T.*(a8+((a9*T)./2)+((a10*(T).^2)./3)+((a11*(T).^3)./4)+((a12*(T).^4)./5)+(a13./T));
else
    H = R*T.*(a1+((a2*T)./2)+((a3*(T).^2)./3)+((a4*(T).^3)./4)+((a5*(T).^4)./5)+(a6./T));
end
end

%MOlecular weight
function W = Molecular_weight(species)

% Defining Atomic name of the species
atomic_name = ['H','C','O','N','Ar'];

% defining atomic masses of main species
atomic_weight =[1.008 12.011 15.999 14.007 39.948];

W=0; % Molecular weight starting range

for i=1:length(species) % loop runs to the length of the species
 for j=1:length(atomic_name) % loop runs to the length of the atomic names
     if strcmp(species(i), atomic_name(j)); % Function to compare 2 strings
         W=W+atomic_weight(j);
         position =  j;
     end
 end
 n=str2num(species); % Now we will find if there is more element in the species then incrementing the atomic weight of the species
 if n>1
     W=W + atomic_weight(position)*(n-1);
 end 
end
fprintf('Molecular Weight of %s : - ', species);
fprintf('%f',W);
disp(' ')
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.