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

16 Ansichten (letzte 30 Tage)
John
John am 1 Okt. 2022
Kommentiert: John am 2 Okt. 2022
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 Kommentare
Torsten
Torsten am 2 Okt. 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 am 2 Okt. 2022
Thank you so much! That worked! I appreciate explaining why it didn't work before. This is a great learning and great value!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 2 Okt. 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.
.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by