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

조회 수: 16 (최근 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 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