Hold on does not work

10 views (last 30 days)
Raymond Kuoch
Raymond Kuoch on 27 Sep 2017
Answered: Walter Roberson on 27 Sep 2017
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 Comment
Jan
Jan on 27 Sep 2017
Please explain, what "does not work" means. What do you observe? What is the problem?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 27 Sep 2017
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.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!