update plot from loop using function

2 visualizaciones (últimos 30 días)
lior lion
lior lion el 22 de Dic. de 2021
Comentada: lior lion el 22 de Dic. de 2021
hi, i have a function analys some data and plot it.
i want to plot a number of figures tgether, using a loup that change the data every loup.
how can i print tham all?
thank a lot!!!!
function [k] = lot_plot(b)
figure
for i=1:n
my_function_that_plot(i)
end
plot(all_of_tham) ?% need to see n figurse in one plot
end
  1 comentario
Mathieu NOE
Mathieu NOE el 22 de Dic. de 2021
hello
it's a bit unclear what data must be displayed in each plot (one plot or multiple subplots ? )
can you clarify ?
tx

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 22 de Dic. de 2021
function [k] = lot_plot(b)
figure
for i=1:n
all_of_tham(:,i) = my_function_that_plot(i, b);
end
semilogx(all_of_tham) % need to see n figurse in one plot
end
Notice that the data was put into different columns . Each column will generate a new line.
  3 comentarios
Walter Roberson
Walter Roberson el 22 de Dic. de 2021
Considering your example structure
for i=1:n
my_function_that_plot(i)
end
plot(all_of_tham)
and you do not want to return anything from the function, then is it correct that you want the function my_function_that_plot to automatically write into the variable all_of_tham that is local to the workspace lot_plot ? That is possible but it is seldom a good idea.
lior lion
lior lion el 22 de Dic. de 2021
ok, got it. you helped me a lot!

Iniciar sesión para comentar.

Más respuestas (1)

lior lion
lior lion el 22 de Dic. de 2021
Editada: lior lion el 22 de Dic. de 2021
hi, i need to see some data in one plot, like this(but a lot more)

Categorías

Más información sobre Annotations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by