Check this function out:
Patch moving with keyboard
5 次查看(过去 30 天)
显示 更早的评论
Hi all, I have a little problem. I have created the patch object in a figure with an axes and then i have placed it at some location using the transformation. Now i want to move it using the arrows or an any other button on my keyboard.
Here is an example:
function[] = main()
fig....
ax...
set(Fig,'KeyPressFcn',@KeybordMoving);
end
function[] = patch()
t=0:pi/2:2*pi;
x=cos(t);
y=sin(t):
handle=patch(x,y,[0 0 0]);
Tx=-1;
T=makehgtform('translate', [Tx 0 0]);
M=T;
AxT=hgtransform('parent', gca, 'matrix', M);
end
function[] = KeboardMoving(hobject, event)
switch event.Key
case 'something'
case 'something'
end
end
Each press on key i would like to move it left or right. thanks for help.
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!