在MATLAB中对CO2马达进行动画处理 [英] Animate CO2 motor in MATLAB
问题描述
我正在尝试在Matlab中重新创建此引擎: http://www.animatedengines.com/co2. html .我希望使用手柄图形来对所有活动部件进行动画处理.我已经编写了所有固定零件.目前,我正在努力使球上下移动,但我无法弄清楚它是如何工作的.我对手柄的工作方式以及如何使球运动所需的知识尚不十分清楚.任何见识将不胜感激.
I am trying to recreate this engine in Matlab: http://www.animatedengines.com/co2.html. I am looking to use handle graphics in order to animate all of the moving parts. I have all of the stationary parts already programmed. Right now I am working on getting the ball to move up and down, but I cannot figure out how it works. I don't have a very clear understanding of how handles work and what I need to do to get the ball to move. Any insight would be greatly appreciated.
推荐答案
以下是一个小圆圈围绕一个大圆圈移动的示例:
Here's an example for a small circle moving around a larger circle:
%# create large-circle coordinates
t = 0:pi/100:2*pi;
xc = cos(t);
yc = sin(t);
%# create small-circle coordinates
xs = 0.1*cos(t);
ys = 0.1*sin(t);
%# plot large circle
figure,plot(xc,yc,'r');
%# plot small circle at first position
%# and capture handle
smallCircleH = plot(xs+xc(1),ys+yc(1),'b');
%# loop to update the handle of the small circle
for tIdx = 1:length(t)
%# update position of small circle
set(smallCircleH,'xData',xs+xc(tIdx),'yData',ys+yc(tIdx));
%# wait a bit to appreciate the beauty
pause(0.1);
end
这篇关于在MATLAB中对CO2马达进行动画处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!