update plot from loop using function
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Mathieu NOE
2021-12-22
hello
it's a bit unclear what data must be displayed in each plot (one plot or multiple subplots ? )
can you clarify ?
tx
采纳的回答
Walter Roberson
2021-12-22
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 个评论
Walter Roberson
2021-12-22
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.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
