Hold on does not work

10 次查看(过去 30 天)
Raymond Kuoch
Raymond Kuoch 2017-9-27
Hi everyone,
I have a probleme with plotting a graph. Indeed, I do not understand why my function "Hold on" does not work.
Here is my script.
Nmin = 2;
Nmax = 100;
abscisses = (Nmin:Nmax);
for N=Nmin:Nmax
A=matrice_A(N);
ordonnees(N-Nmin+1)=cond(A);
end
plot(abscisses,ordonnees,'b');
hold on;
plot(abscisses,(4/(pi^2))*(abscisses+1).^2,'r');
Here is my function matrice_A .
function [ A ] = matrice_A( N )
A = diag(2*ones(1,N),0)-diag(ones(1,N-1),-1)-diag(ones(1,N-1),1);
end
Thanks for advance !!
  1 个评论
Jan
Jan 2017-9-27
Please explain, what "does not work" means. What do you observe? What is the problem?

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2017-9-27
Look at
Nmin = 2;
Nmax = 100;
abscisses = (Nmin:Nmax);
for N=Nmin:Nmax
A=matrice_A(N);
ordonnees(N-Nmin+1)=cond(A);
end
plot(abscisses,ordonnees,'b');
hold on;
o2 = (4/(pi^2))*(abscisses+1).^2;
plot(abscisses,o2,'r');
figure();
plot(abscisses, ordonnees - o2, 'g');
You will see that the difference between the two plots is less than about 0.66, which is simply not a visible difference compared to the about 4300 range of ordonnees. If you zoom way in on the first plot you can see that the two lines are both there.

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by