現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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
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 件のコメント
Adi Mico
2011 年 8 月 11 日
I've tried your codes, but the result is this
Error using ==> coba>mytimer
Too many input arguments.
Adi Mico
2011 年 8 月 11 日
the figure's name is coba
and the timer's name is mytimer
Friedrich
2011 年 8 月 11 日
Could you post your code? The example given above works fine. Try to take the main idea and put it in your code.
Adi Mico
2011 年 8 月 11 日
function timer_Callback(hObject, eventdata, handles)
T1=timer;
T2=timer;
set(T1,'ExecutionMode','fixedRate','BusyMode','drop','Period',1);
set(T2,'ExecutionMode','fixedRate','BusyMode','drop','Period',1);
set(T1, 'TimerFcn', @(obj, event) timerkirim(obj, event, handles));
set(T2, 'TimerFcn', @(obj, event) mytimer(obj, event, handles));
setappdata(0,'T1',T1);
setappdata(0,'T2',T2);
start(T1);
start(T2);
function mytimer(obj, event)
print(handles.axes1,'-dtiff',['signal_',num2str(get(obj,'TasksExecuted'))]);
the timerkirim is timer to update the plot
Friedrich
2011 年 8 月 11 日
Your TimerFcn passed 3input args
set(T1, 'TimerFcn', @(obj, event) timerkirim(obj, event, handles));
But the mytimer function has only two. This would match with the error you get: Too many input arguments.
Try it that way:
set(T2, 'TimerFcn', {@mytimer,handles});
function mytimer(obj, event, handles)
print(handles.axes1,'-dtiff',['signal_',num2str(get(obj,'TasksExecuted'))]);
Friedrich
2011 年 8 月 11 日
Look here for the right callback function syntax:
http://www.mathworks.com/help/releases/R2011a/techdoc/matlab_prog/f9-39541.html#f9-42494
Friedrich
2011 年 8 月 11 日
Did you try ma suggestions? This wont work
set(T1, 'TimerFcn', @(obj, event) timerkirim(obj, event, handles));
set(T2, 'TimerFcn', @(obj, event) mytimer(obj, event, handles));
For T2 it have to look like this
set(T2, 'TimerFcn', {@mytimer,handles});
and the mytimer function must look like this
function mytimer(obj, event, handles)
print(handles.axes1,'-dtiff',['signal_',num2str(get(obj,'TasksExecuted'))]);
Adi Mico
2011 年 8 月 11 日
Still got error:
Error using ==> print at 310
Handle Graphics handle must be a Figure.
Friedrich
2011 年 8 月 11 日
handles.axes1 is an axis handle. but print need the handle of the figure.
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 件)
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
