Code display blank plot

5 ビュー (過去 30 日間)
Omer Yaish Maman
Omer Yaish Maman 2020 年 5 月 11 日
コメント済み: Image Analyst 2020 年 5 月 11 日
My code is calculating a non-linear equation system with Newton-Rhapson method, and I'm trying to show a plot of "iterration"(i) as function of "error vector"(h1).
Maybe because i is scalar and h1 is a vector?
How can i fix the code for making a plot like i want?
syms x y z
u = (x*y)-z^3-2;
v = (x*y*z)-x^2+y^2-4;
w = exp(x)-exp(y)+cos(z)-6;
xo = 1;yo = 1;zo = 1;
k = 10;
i = 0;
a = jacobian([u;v;w],[x,y,z]);
while i<k
j=subs(a,[x,y,z],[xo,yo,zo]);
j_i=j^-1;
uo=subs(u,[x,y,z],[xo,yo,zo]);
vo=subs(v,[x,y,z],[xo,yo,zo]);
wo=subs(w,[x,y,z],[xo,yo,zo]);
sol=[xo;yo;zo]-j_i*[uo;vo;wo];
sol=double(sol);
x1=sol(1,1);
h1=j_i*[uo;vo;wo];
xo=sol(1,1);
yo=sol(2,1);
zo=sol(3,1);
i=i+1;
plot(i,h1,'r');
hold on
xlabel('Error Vector')
ylabel('Iterration')
end
X=xo;
Y=yo;
Z=zo;
X,Y,Z
  2 件のコメント
dpb
dpb 2020 年 5 月 11 日
Probably just that a single pixel is too small to show up on the screen...try
plot(i,h1,'rx','markersize',3);
Omer Yaish Maman
Omer Yaish Maman 2020 年 5 月 11 日
Thank you very musch that was helpful

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

回答 (1 件)

Image Analyst
Image Analyst 2020 年 5 月 11 日
編集済み: Image Analyst 2020 年 5 月 11 日
Try this:
plot(1 : length(h1), h1, 'r.', 'MarkerSize', 15);
grid on;
hold on
drawnow;
or simply
plot(h1, 'r.', 'MarkerSize', 15);
grid on;
hold on
drawnow;
  1 件のコメント
Image Analyst
Image Analyst 2020 年 5 月 11 日
Glad changing the markersize fixed it for you.

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

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by