Can anyone Solve the Error.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ahmed Saleem
am 31 Dez. 2020
Kommentiert: Ahmed Saleem
am 1 Jan. 2021
clc
% Part a
% ps1=exp (16.59158-(3643.31/(t-33.424)))
% ps2=exp (14.25326-(2665.54/(t-53.424)))
% T = 318.15 K and x1 = 0.25
t=318.15;
p=zeros(1,21);
for i=1:0.05:2
syms x2 ps1 ps2 p y1 y2
x1=i-1;
x2=1-x1;
k=round(((i-1+0.05)/0.05),0)
ps1 = exp (16.59158-(3643.31/(t-33.424)));
ps2 = exp (14.25326-(2665.54/(t-53.424)));
eqn1= p-((x1*ps1)+(x2*ps2))==0;
p(1,k)= vpa(solve(eqn1))
eqn2= y1-((x1*ps1)/p(1,k))==0;
y1(1,k)= vpa(solve(eqn2))
eqn3= y2-((x2*ps2)/p(1,k))==0;
y2(1,k)= vpa(solve(eqn3))
end
plot(y1,p)
Command Window:
k =
21
p =
[ p, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44.510902949867883648948918562382]
y1 =
[ y1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0]
y2 =
[ y2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Error using plot
Non-numeric data is not supported in 'Line'
Error in Sample13 (line 22)
plot(y1,y2)
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 31 Dez. 2020
t=318.15;
p=zeros(1,21);
syms x2 ps1 ps2 p y1 y2
for i=1:0.05:2
x1=i-1;
x2=1-x1;
k=round(((i-1+0.05)/0.05),0);
ps1 = exp (16.59158-(3643.31/(t-33.424)));
ps2 = exp (14.25326-(2665.54/(t-53.424)));
eqn1= p-((x1*ps1)+(x2*ps2))==0;
P(1,k)= vpa(solve(eqn1));
eqn2= y1-((x1*ps1)/P(1,k))==0;
Y1(1,k)= vpa(solve(eqn2));
eqn3= y2-((x2*ps2)/P(1,k))==0;
Y2(1,k)= vpa(solve(eqn3));
end
Y1
P
plot(Y1,P)
4 Kommentare
Walter Roberson
am 31 Dez. 2020
Yes I moved the syms outside of the loop, and I assign to P and Y1 and Y2 instead of p and y1 and y2.
Every time you syms the entire previous content of the variable is thrown away.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Formula Manipulation and Simplification finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!