在MATLAB GUI中循环

鲁西克·图马尔(Rushik Thumar)

我正在建立MATLAB与Ascention Trakstar(运动)传感器之间的实时接口。在此任务中,我在MATLAB GUI图形窗口(全尺寸屏幕)上以正方形显示实时传感器位置。

我想显示各种形状的传感器位置(现在将焦点放在圆形上)。如何在MATLAB GUI图形窗口中绘制圆?以及如何通过MATLAB实时圈出手柄?

非常感谢。

Matlabgui

您需要在轴上绘制->,但可以将可见性设置为off。

在下面,您将找到一个如何通过鼠标移动绘制圆和更新位置的示例。它可以帮助您入门...

function circleExample
  f = figure;
  ax = axes ( 'parent', f, 'Position', [0 0 1 1] );
  % circle diameter
  d = 2;

  % center of circle.
  c = [10 10];

  % Create position of circle.
  pos = [c-d/2 d d];
  % Create circle via rect command.
  h = rectangle('Position',pos,'Curvature',[1 1]);
  % make sure its looks like a circle.
  axis equal
  % Update some axes properties
  set ( ax, 'visible', 'off', 'XLim', [0 20], 'YLim', [0 20], 'XLimMode', 'manual', 'YLimMode', 'manual' );

  % Add a callback to the figure to update the position when the circle moves
  set ( f, 'WindowButtonMotionFcn', @(a,b)UpdateCirclePos ( ax, h, d ) )
end
function UpdateCirclePos ( ax, h, d )
  cp = get ( ax, 'CurrentPoint' );
  h.Position = [cp(1,1) cp(1,2) d d];
end

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章