필터 지우기
필터 지우기

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 CenterFile Exchange에서 Conversion 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