Save plot every second in different file image

1 次查看(过去 30 天)
Please Help me.
I have the program of monitoring signal which I use plot function to view the signal. Because I use the timer function, the plot changed every second. What I want is I can save that plot for every second, let say for 10 seconds. What will I to do so the plots are saved in a file with different named? say file 1.tiff for signal 1, file 2.tiff for signal 2, and so on.

采纳的回答

Friedrich
Friedrich 2011-8-10
Hi,
in the function which is called from the timer (TimerFcn callback) before updating the plot you can save it. Lets say the TimerFcn is named
timer('TimerFcn',@my_func, 'Period', 1.0);
Than you create my_func as follows
function my_func(obj,event )
This will pass the timer object to my_func in every call. The timer object has a property called 'TasksExecuted'. With this property you can create dynamic file names easily as follows:
%before updating the plot
print(handle_to_plot,'-dtiff',['signal_',num2str(get(obj,'TasksExecuted'))]);
%update plot
More specific:
t = timer('TimerFcn',@my_func, 'Period', 1.0,'ExecutionMode','fixedRate');
start(t);
function my_func(obj,event )
get(obj,'TasksExecuted')
end
  10 个评论
Friedrich
Friedrich 2011-8-11
handles.axes1 is an axis handle. but print need the handle of the figure.
Adi Mico
Adi Mico 2011-8-11
It worked if I write this code:
print(coba,'-dtiff',['signal_',num2str(get(obj,'TasksExecuted'))]);
At first moment there is some crush maybe because the program locating the destination image file but after a while it work with some vibration.
But it fine for me.
Thank you very much Mr.Friedrich..

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by