フィルターのクリア

Can anyone Solve the Error.

1 回表示 (過去 30 日間)
Ahmed Saleem
Ahmed Saleem 2020 年 12 月 31 日
コメント済み: Ahmed Saleem 2021 年 1 月 1 日
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)

採用された回答

Walter Roberson
Walter Roberson 2020 年 12 月 31 日
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 件のコメント
Walter Roberson
Walter Roberson 2020 年 12 月 31 日
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 2021 年 1 月 1 日
Thanks mate.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by