Not getting the right root when using solve

4 views (last 30 days)
The answer I'm getting is - 775.94006610198792379207269683591 + 890.01055416454391218342305188902*i My answer should be around 515 any suggestions
here's how I was solving, all variables are given except T2
%Set up Variable T2 = final Temperature for Isentropic process
syms T2
%s2 = s(T) of equation 9
%Utilize Matlab solve for Variable T2
Tfinal=solve(s2-s0 == a.*log(T2 ./T0)+b.*(T2 -T0)+.5*c.*(T2.^2-T0^2)+d.*(T2.^3-T0^3)/3+.25*e.*(T2.^4-T0^4),T2)
  6 Comments
Tyler
Tyler on 27 Apr 2013
Note I get the right answer when using Air
Zhang lu
Zhang lu on 27 Apr 2013
Edited: Zhang lu on 27 Apr 2013
function [ ] = Isentropic( TA, P1, P2 )
%This Mfile finds the final temperature of an isentropic process for Air
% Intial Temp and Initial / Final pressures are given
prompt='What Gas Are We Dealing With?(Type 1 for Air or 2 for Oxygen)';
result=input(prompt);
if result == 1
T0=300; %K
s0=1.70203;%kJ/kg-K
%For Ideal Air %Gas Constant
R=.2869; %kJ/kg K
alpha=3.653;
beta=-1.337*10^-3;
gamma=3.294*10^-6;
delta=-1.913*10^-9;
elpison=0.2763*10^-12;
elseif result == 2 %Oxygen
%Set Reference State @ 300K
T0= 300; %K
s0=205.213;%kJ/kmol-K
R=8.314; %kJ/kg-mol-K
alpha=3.626;
beta=-1.878*10^-3;
gamma=7.055*10^-6;
delta=-6.764*10^-9;
elpison=2.156*10^-12;
else error('Please Try Again and Choose Air(1) or Oxygen(2)')
end
%Equation 3
a=alpha*R;
b=beta*R;
c=gamma*R;
d=delta*R;
e=elpison*R;
%Find Specific entropy 1 = s1
s1 = a.*log(TA ./T0)+b.*(TA -T0)+.5*c.*(TA.^2-T0^2)+d.*(TA.^3-T0^3)/3+.25*e.*(TA.^4-T0^4)+s0;
%Find Specific entropy 2 = s2
s2=s1+R.*log(P2./P1);
%Set up Variable T2 = final Temperature for Isentropic process
syms T2
%s2 = s(T) of equation 9
%Utilize Matlab solve for Variable T2
Tfinal=solve(a*log(T2 /T0)+b*(T2 -T0)+.5*c*(T2^2-T0^2)+d*(T2^3-T0^3)/3+.25*e*(T2^4-T0^4)-s2+s0,'T2')
end

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 27 Apr 2013
Try
syms T2 real
  1 Comment
Tyler
Tyler on 27 Apr 2013
Edited: Tyler on 27 Apr 2013
Thanks you're a life saver...I really appreciate it, The program works now...that was easier then I thought

Sign in to comment.

More Answers (0)

Categories

Find more on Robust Control Toolbox 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!