Sometimes my 2-D plots won't show up.

12 ビュー (過去 30 日間)
John
John 2022 年 10 月 1 日
コメント済み: John 2022 年 10 月 2 日
My 2-D plots will sometimes not plot. Sometimes they work, and sometimes they won't plot, and I can't figure out why. I'm very new to Matlab so it's probably something basic that i'm not doing correctly. The "New Figure option" in the Plots menu is checked.
  4 件のコメント
Torsten
Torsten 2022 年 10 月 2 日
Replace
y=K*(1+(Fb0*x/Na0))-realsqrt(((K*(1+Fb0*x/Na0))^2)-4*(K-1)*K*Fb0*x/Na0)/2*(K-1);
by
y=K*(1+(Fb0*x/Na0))-realsqrt(((K*(1+Fb0*x/Na0)).^2)-4*(K-1)*K*Fb0*x/Na0)/2*(K-1);
John
John 2022 年 10 月 2 日
Thank you so much! That worked! I appreciate explaining why it didn't work before. This is a great learning and great value!

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

採用された回答

Star Strider
Star Strider 2022 年 10 月 2 日
Normally, that sort of problem is caused by using matrix division (/) instead of element-wise array division (./) however the ‘x’ vector does not appear in the denominator, so that is not the problem here. The only problem I found is that you need to use element-wise exponentiation (.^ instead of ^):
y=K*(1+(Fb0*x/Na0))-realsqrt(((K*(1+Fb0*x/Na0)).^2)-4*(K-1)*K*Fb0*x/Na0)/2*(K-1)
↑ ← HERE
however that should throw an error.
With that change, I don’t see any problems —
Fb0=0.5465;
Na0=1544;
K=8.33*10^-5;
x=0:36000:360000;
y=K*(1+(Fb0*x/Na0))-realsqrt(((K*(1+Fb0*x/Na0)).^2)-4*(K-1)*K*Fb0*x/Na0)/2*(K-1)
y = 1×11
0.0001 0.0337 0.0483 0.0597 0.0695 0.0783 0.0863 0.0938 0.1008 0.1075 0.1138
plot(x,y);
The drawnow function us usually used with animated plots. Since it doesn’t appear to be appropriate here, I don’t use it.
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by