Hold on does not work
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Jan
le 27 Sep 2017
Please explain, what "does not work" means. What do you observe? What is the problem?
Réponses (1)
Walter Roberson
le 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.
0 commentaires
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!