Hold on does not work
10 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!