Overlapping graphs in figure
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Diego Núñez García
le 5 Juil 2021
Commenté : Sulaymon Eshkabilov
le 6 Juil 2021
Here is part of my code. I'm ploting two graphs evaluating several polynomials , I use "delete(gca) and clf " at the begining of the code, but when I run the script with another vaules, I receive in figure(1) the last plot and the actual one.
i=0
figure(1)
hold on
for i=1:length(nodos)-1
plot([nodos(i):0.01:nodos(i+1)],polyval([Mx(:,:,i)],[nodos(i):0.01:nodos(i+1)]),'Color','b','LineWidth',2.5)
hold on
end
xlabel('Longitud de la Viga [m]')
ylabel('Fuerza cortante[N]')
yline(0)
i=0
figure(2)
for i=1:length(nodos)-1
plot([nodos(i):0.01:nodos(i+1)],polyval([Vx(:,:,i)],[nodos(i):0.01:nodos(i+1)]),'Color','b','LineWidth',2.5)
hold on
end
xlabel('Longitud de la Viga [m]')
ylabel('Momento Flector [n*M]')
yline(0)

1 commentaire
Image Analyst
le 5 Juil 2021
Well, we don't have nodos, Vx, and Mx so it's hard for us to reproduce your code or fix it. Please attach your variables in a .mat file with the paperclip icon after you read this:
To save your variables in a .mat file, do this:
save('answers.mat', 'nodos', 'Mx', 'Vx');
Réponse acceptée
Sulaymon Eshkabilov
le 5 Juil 2021
Here is a bit edited and corrected code:
figure()
for i=1:length(nodos)-1
plot([nodos(i):0.01:nodos(i+1)],polyval([Mx(:,:,i)],[nodos(i):0.01:nodos(i+1)]),'-','LineWidth',2.5)
hold on % Different colored lines
end
xlabel('Longitud de la Viga [m]')
ylabel('Fuerza cortante[N]')
yline(0)
figure()
for i=1:length(nodos)-1
plot([nodos(i):0.01:nodos(i+1)],polyval([Vx(:,:,i)],[nodos(i):0.01:nodos(i+1)]),'-','LineWidth',2.5)
hold all % % Different colored lines
end
xlabel('Longitud de la Viga [m]')
ylabel('Momento Flector [n*M]')
yline(0)
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!