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

17 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by