Effacer les filtres
Effacer les filtres

Can anyone Solve the Error.

1 vue (au cours des 30 derniers jours)
Ahmed Saleem
Ahmed Saleem le 31 Déc 2020
Commenté : Ahmed Saleem le 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)

Réponse acceptée

Walter Roberson
Walter Roberson le 31 Déc 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
Y1 = 
P
P = 
plot(Y1,P)
  4 commentaires
Walter Roberson
Walter Roberson le 31 Déc 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.
Ahmed Saleem
Ahmed Saleem le 1 Jan 2021
Thanks mate.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by