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

16 views (last 30 days)
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 Comments
Torsten
Torsten on 2 Oct 2022
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 on 2 Oct 2022
Thank you so much! That worked! I appreciate explaining why it didn't work before. This is a great learning and great value!

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 2 Oct 2022
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.
.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!