update plot from loop using function

조회 수: 2 (최근 30일)
lior lion
lior lion 2021년 12월 22일
댓글: lior lion 2021년 12월 22일
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
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
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
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.
lior lion
lior lion 2021년 12월 22일
ok, got it. you helped me a lot!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

lior lion
lior lion 2021년 12월 22일
편집: lior lion 2021년 12월 22일
hi, i need to see some data in one plot, like this(but a lot more)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by