Matlab solver function variable question
I have to write a matlab code to solve for some numbers using given 1-D flow with heat added equations.
I need to solve for a variable M2, using the following relation
To2/To1=(1.480988*M2^4-7.40494*M2^2)/(M2^4+1.4285714*M2^2+.5102)
with To2 as a variable defined by
To2=(Qo*l)/(Cp)+To1 where Qo, Cp, l and To1 are knowns.
When i try to run the full program i get the following error:
??? Undefined function or method 'solve' for input arguments of type 'char'.
Error in ==> Hw73 at 20
solve('To2/To1=(1.480988*M2^4-7.40494*M2^2)/(M2^4+1.4285714*M2^2+.5102)','M2')
Here is my full code:
V1=100;
T1=293;
P1=101.3;
Qo=4*10^4;
g=1.4;
R=287.5;
Cp=1005;
M1=sqrt((V1)^2/(g*R*T1))
To1=T1*(1+((g-1)/2)*(M1)^2)
%s=star conditions
%T1/Ts=Tratio1
%P1/Ps=Pratio1
%Po1/Pos=Poratio1
Tratio1=((1+g)^2*M1^2)/(1+g*M1^2)^2
Pratio1=(1+g)/(1+g*M1^2)
Poratio1=((1+g)/(1+g*M1^2))*((2*(1+((g-1)/2)*(M1)^2))/(1+g))^(1.4/(1.4-1))
for l=0:1:12
To2=(Qo*l)/(Cp)+To1
solve('To2/To1=(1.480988*M2^4-7.40494*M2^2)/(M2^4+1.4285714*M2^2+.5102)','M2')
M2
%T2/Ts=Tratio2
%P2/Ps=Pratio2
%Po2/Pos=Poratio2
Tratio2=((1+g)^2*M2^2)/(1+g*M2^2)^2;
Pratio2=(1+g)/(1+g*M2^2);
Poratio2=((1+g)/(1+g*M2^2))*((2*(1+((g-1)/2)*(M2)^2))/(1+g))^(1.4/(1.4-1));
To=To2/To1;
T=Tratio2/Tratio1;
P=Pratio2/Pratio1;
Po=Poratio2/Poratio1;
end
HELP please? anything is appricated
I need to solve for a variable M2, using the following relation
To2/To1=(1.480988*M2^4-7.40494*M2^2)/(M2^4+1.4285714*M2^2+.5102)
with To2 as a variable defined by
To2=(Qo*l)/(Cp)+To1 where Qo, Cp, l and To1 are knowns.
When i try to run the full program i get the following error:
??? Undefined function or method 'solve' for input arguments of type 'char'.
Error in ==> Hw73 at 20
solve('To2/To1=(1.480988*M2^4-7.40494*M2^2)/(M2^4+1.4285714*M2^2+.5102)','M2')
Here is my full code:
V1=100;
T1=293;
P1=101.3;
Qo=4*10^4;
g=1.4;
R=287.5;
Cp=1005;
M1=sqrt((V1)^2/(g*R*T1))
To1=T1*(1+((g-1)/2)*(M1)^2)
%s=star conditions
%T1/Ts=Tratio1
%P1/Ps=Pratio1
%Po1/Pos=Poratio1
Tratio1=((1+g)^2*M1^2)/(1+g*M1^2)^2
Pratio1=(1+g)/(1+g*M1^2)
Poratio1=((1+g)/(1+g*M1^2))*((2*(1+((g-1)/2)*(M1)^2))/(1+g))^(1.4/(1.4-1))
for l=0:1:12
To2=(Qo*l)/(Cp)+To1
solve('To2/To1=(1.480988*M2^4-7.40494*M2^2)/(M2^4+1.4285714*M2^2+.5102)','M2')
M2
%T2/Ts=Tratio2
%P2/Ps=Pratio2
%Po2/Pos=Poratio2
Tratio2=((1+g)^2*M2^2)/(1+g*M2^2)^2;
Pratio2=(1+g)/(1+g*M2^2);
Poratio2=((1+g)/(1+g*M2^2))*((2*(1+((g-1)/2)*(M2)^2))/(1+g))^(1.4/(1.4-1));
To=To2/To1;
T=Tratio2/Tratio1;
P=Pratio2/Pratio1;
Po=Poratio2/Poratio1;
end
HELP please? anything is appricated
0
Comments
The solve function requires the data from To2 defined earlier in the code. I
cant just write the solve equation into the command prompt or i get the same error.