Hold on does not work

10 visualizaciones (últimos 30 días)
Raymond Kuoch
Raymond Kuoch el 27 de Sept. de 2017
Respondida: Walter Roberson el 27 de Sept. de 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 comentario
Jan
Jan el 27 de Sept. de 2017
Please explain, what "does not work" means. What do you observe? What is the problem?

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 27 de Sept. de 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.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by