【问题标题】:Animation in matlab using axis plot - controlmatlab中的动画使用轴图 - 控制
【发布时间】:2014-12-26 20:06:25
【问题描述】:

所以基本上我有一个 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

【问题讨论】:

  • 所以这段代码在按钮回调中? y 是什么?
  • y 对应于时间解图,它是 [y,t]=step(sys) 形式的步进输入图;轴(handles.axes5)轴([0,9,0,20])

标签: image matlab user-interface plot position


【解决方案1】:

我怀疑您的图像由于进程繁忙而没有显示。

如果你有一个在一个过程中更新的 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

关于您的代码有很多问题要准确修复它:

您需要考虑的几点:

  1. 轴单位“通常”是标准化的 - 也许您已经在代码中更改了它 - 不清楚。
  2. 您应该在循环之前加载图像,而不是每次调用 imshow 时都加载它。
  3. 建议明确说明要在哪些轴上执行操作(例如,上面的父调用) - 你的应该是 handle.axes5
  4. 您无需在循环中刷新整个绘图(cla、等等...),只需移动轴即可。

【讨论】:

  • 它不起作用。它打开了另一个窗口,该图没有显示,也没有动画。你知道如何在我当前的轴上设置动画吗?轴标签是 axes5
猜你喜欢
  • 2023-02-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-15
  • 2015-01-22
  • 2014-12-30
  • 2020-10-24
  • 2018-10-25
相关资源
最近更新 更多