Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Not getting the right root when using solve

Asked by Tyler

Tyler (view profile)

on 26 Apr 2013

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 (view profile)

on 27 Apr 2013

a,b,c,d,e are constants based on experimental data. T0 is the reference property temperature (it is 300K for both gases)

Tyler

Tyler (view profile)

on 27 Apr 2013

Note I get the right answer when using Air

Zhang lu

Zhang lu (view profile)

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

Tyler

Tyler (view profile)

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson

Walter Roberson (view profile)

on 27 Apr 2013
Accepted answer

Try

syms T2 real

1 Comment

Tyler

Tyler (view profile)

on 27 Apr 2013

Thanks you're a life saver...I really appreciate it, The program works now...that was easier then I thought

Walter Roberson

Walter Roberson (view profile)

Contact us