Value of the array in calculation and graph is different
4 views (last 30 days)
Show older comments
k=10;
Es=0.05;
t=273;
TempK=0:1500;
cp=0:0.2:1.2;
cp=0.99403+((1.671e-4)*(TempK))+((9.7215e-8)*(TempK.^2))-((9.5838e-11)*(TempK.^3))+((1.9520e-14)*(TempK.^4));
plot(TempK,cp,'r',LineWidth=2);
title('Specific Heat Capacity, C_p (kJ/kg\cdotK) VS Temperature (K)');
xlabel('Temperature, T (K)');
ylabel('Specific Heat Capacity, C_p (kJ/kg\cdotK)');
grid on
tarr=zeros(1,k);
cp1arr=zeros(1,k);
for i=1:k
T=(((0.20597+((9.5838e-11)*(t.^3))-((9.7215e-8)*(t.^2))-((1.671e-4)*t)))/(1.9520e-14)).^(1/4);
tnew=T;
Ea=abs((((tnew-t)/tnew)*100));
cp1=0.99403+((1.671e-4)*(T))+((9.7215e-8)*(T.^2))-((9.5838e-11)*(T.^3))+((1.9520e-14)*(T.^4));
if Ea<Es
disp('---------------------------------------------');
disp(['Iteration,k = ',num2str(i,k)]);
disp(['Cp = ',num2str(cp1),' kJ/kgK'])
disp(['t = ',num2str(t)]);
disp(['t new = ',num2str(tnew)]);
disp(['Ea = ',num2str(Ea), ' %']);
break;
end
t=tnew;
disp('---------------------------------------------');
disp(['Iteration,k = ',num2str(i,k)]);
disp(['Cp = ',num2str(cp1),' kJ/kgK'])
disp(['t = ',num2str(t)]);
disp(['t new = ',num2str(tnew)]);
disp(['Ea = ',num2str(Ea),' %']);
cp1arr(1,i)=cp1;
tarr(1,i)=t;
i=i+1;
end
hold on
plot(tarr,cp1arr,'g',LineWidth=2)
legend('f_1(T)','f_2(T)')
0 Comments
Answers (1)
VBBV
on 26 Nov 2022
Edited: VBBV
on 26 Nov 2022
format long
k=10;
Es=0.05;
t=273;
TempK=0:1500;
cp=0:0.2:1.2;
cp=0.99403+((1.671e-4)*(TempK))+((9.7215e-8)*(TempK.^2))-((9.5838e-11)*(TempK.^3))+((1.9520e-14)*(TempK.^4));
plot(TempK,cp,'r',LineWidth=1.5);
title('Specific Heat Capacity, C_p (kJ/kg\cdotK) VS Temperature (K)');
xlabel('Temperature, T (K)');
ylabel('Specific Heat Capacity, C_p (kJ/kg\cdotK)');
grid on
tarr=zeros(1,k);
cp1arr=zeros(1,k);
for i=1:k
T=((((0.20597./t.^4)+((9.5838e-11)./(t))-((9.7215e-8)./(t.^2))-((1.671e-4)./t.^3)))/(1.9520e-14)).^(1/4);
tnew=T;
Ea=abs((((tnew-t)/tnew)*100));
cp1=0.99403+((1.671e-4)*(T))+((9.7215e-8)*(T.^2))-((9.5838e-11)*(T.^3))+((1.9520e-14)*(T.^4));
% if Ea<Es
% disp('---------------------------------------------');
% disp(['Iteration,k = ',num2str(i,k)]);
% disp(['Cp = ',num2str(cp1),' kJ/kgK'])
% disp(['t = ',num2str(t)]);
% disp(['t new = ',num2str(tnew)]);
% disp(['Ea = ',num2str(Ea), ' %']);
% break;
% end
t=tnew;
% disp('---------------------------------------------');
% disp(['Iteration,k = ',num2str(i,k)]);
% disp(['Cp = ',num2str(cp1),' kJ/kgK'])
% disp(['t = ',num2str(t)]);
% disp(['t new = ',num2str(tnew)]);
% disp(['Ea = ',num2str(Ea),' %']);
cp1arr(1,i)=cp1;
tarr(1,i)=t;
end
cp1arr, cp % check using format long option
hold on
plot(tarr,cp1arr,'k-',LineWidth=1)
legend('f_1(T)','f_2(T)')
2 Comments
VBBV
on 26 Nov 2022
While obtaining new temperature profile, you may need the below changes
T=((((0.20597./t.^4)+((9.5838e-11)./(t))-((9.7215e-8)./(t.^2))-((1.671e-4)./t.^3)))/(1.9520e-14)).^(1/4);
See Also
Categories
Find more on Particle & Nuclear Physics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!