フィルターのクリア

Help with for loop

1 回表示 (過去 30 日間)
Angelina Encinias
Angelina Encinias 2022 年 3 月 11 日
編集済み: Torsten 2022 年 3 月 11 日
Need to display the two graphs in the question. I am having a hard time with the for loop.

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 3 月 11 日
You have a for i loop 1 to the number of elements in X
Inside that loop you have
for i=1,2;
Notice that you are reusing the variable name i, interfering with i from the outer loop.
Notice that you used 1,2 not 1:2
  8 件のコメント
Angelina Encinias
Angelina Encinias 2022 年 3 月 11 日
Heres my edited code but nothing is showing on the figures?
Torsten
Torsten 2022 年 3 月 11 日
編集済み: Torsten 2022 年 3 月 11 日
a = 1.4106;
b = 1.3438;
Pvap1 = 1.1541;
Pvap2 = 0.7609;
gamma1 = @(x1) exp(a./(1+(a/b)*x1./(1-x1)).^2);
gamma2 = @(x2) exp(b./(1+(b/a)*x2./(1-x2)).^2);
x1 = 0:0.01:1;
x2 = 1 - x1;
P = x1.*gamma1(x1)*Pvap1 + x2.*gamma2(x2)*Pvap2;
y1 = x1.*gamma1(x1)*Pvap1./P;
figure(1)
plot(x1,P)
hold on
plot(y1,P)
figure(2)
plot(x1,y1)

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by