Multiple plots in one m file

65 visualizaciones (últimos 30 días)
D.J
D.J el 3 de Sept. de 2018
Respondida: D.J el 3 de Sept. de 2018
Hello all, my .m file includes multiple plots. When I run the code only the last plot figure shows up and overwrites all previous plots. Any suggestion on how to manage this ?
Many thanks
  1 comentario
jonas
jonas el 3 de Sept. de 2018
Editada: jonas el 3 de Sept. de 2018
How do you initate a figure? Some code would be useful here.

Iniciar sesión para comentar.

Respuesta aceptada

Gabor Balazs
Gabor Balazs el 3 de Sept. de 2018
Your first plot command opens a figure and all following plot commands update that figure. To open new figure windows, use
figure()
for each window you want to open.
figure(1)
plot(1:10)
figure(2)
mesh(randn(10))

Más respuestas (2)

Dimitris Kalogiros
Dimitris Kalogiros el 3 de Sept. de 2018
Before using plot() command you should place a "figure" command
For example:
clc; clear; close all;
t=0:0.1:10;
x=sin(2*pi*3.*t);
y=sqrt(t)+cos(2*pi.*t);
figure;
plot(t,x,'-b'); zoom on; grid on;
figure;
plot(t,y,'-r'); zoom on; grid on;

D.J
D.J el 3 de Sept. de 2018
Wonderful, thanks a lot for your quick help !

Categorías

Más información sobre Graphics Objects 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