Overlapping graphs in figure

2 visualizaciones (últimos 30 días)
Diego Núñez García
Diego Núñez García el 5 de Jul. de 2021
Comentada: Sulaymon Eshkabilov el 6 de Jul. de 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 comentario
Image Analyst
Image Analyst el 5 de Jul. de 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');

Iniciar sesión para comentar.

Respuesta aceptada

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 5 de Jul. de 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 comentarios
Diego Núñez García
Diego Núñez García el 6 de Jul. de 2021
Thank you, you solved my problem
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 6 de Jul. de 2021
You are most welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by