How to make ball move in simulink

3 次查看(过去 30 天)
i have simple sphere (ball) in matlab simulink.
And what i want to do is to make this ball goes around screen (from one corner to another). I was able to do this in matlab with circle in plot with this code. But now i need to do this in simulink.
% START MOVING BALL
X = 2;
Y = 2;
pH = plot(X,Y,'or','MarkerSize',20,'MarkerFaceColor','r');
axis([0 151 0 85])
axis off
for i=1:4560
if i < 1470
X = X + 0.1;
elseif i < 2280
Y = Y + 0.1
elseif i < 3750
X = X - 0.1;
elseif i < 4560
Y = Y - 0.1
end
set(pH,'XData',X,'YData',Y)
tic;while toc<0;end
drawnow
end
% END MOVING BALL
end
But i dont know how to do this in simulink cos i never work with this before. If u can point me somwhere or show me how to do it i will be verz thankful.

采纳的回答

Anmol Dhiman
Anmol Dhiman 2020-11-9
Hi Juraj,
I think animations in simulink is what you are looking for.
Regards,
Anmol Dhiman

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by