[英]Animation in matlab using axis plot - control
所以基本上我有一個GUI並有一個軸圖。
我希望我的圖形具有單擊“計算”按鈕時向上和向下移動的圖像。 有人會指導我如何進行此操作嗎? 使用位置命令? 注意,該圖對應於帶有時間響應圖的控制系統的運動。 因此,隨着系統變得穩定,圖像移動將停止(某些位置)。 到目前為止,我的圖像甚至還沒有出現在軸上!在matlab上任何幫助將不勝感激!
for frame=1:1:length(t)
if stop ~= 1
axes(handles.axes5)
cla;
hold on;
if y(frame)<=0
axes(handles.axes5,'position',[3,y(frame)+0.001,3,((y(frame)+1.0000000001))]);
imshow('ball.jpg','position',[3,0.001,3,(1.00000000001)]);
else
axes(handles.axes5,'position',[3,y(frame)+0.001,3,((y(frame)+1.0000000001))]);
imshow('ball.jpg','position',[3,y(frame)+0.001,3,((y(frame)+1.0000000001))]);
end
我懷疑您的圖片由於進程繁忙而無法顯示。
如果您的GUI在過程中進行了更新,則需要告訴Matlab重繪。 您可以通過添加以下命令來實現
drawnow
更新圖像位置后,請放入此位置。
編輯帶有運動軸示例的更新。
d = figure;
ax = axes ( 'parent', d );
I = imread('pout.tif');
imshow ( I, 'parent', ax );
offset = 0.01;
for i=1:1000
position = get ( ax, 'position' );
position(1) = position(1) + offset;
% if image off right hand side of page - change offset
if position(1) + position(3) >=1
offset = -offset;
% if image off left hand side of page - change offset
elseif position(1) <= 0
offset = -offset;
end
set ( ax, 'position', position );
drawnow()
end
關於您的代碼,要對其進行精確修復有很多問題:
需要考慮的幾點:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.