How to make ball move in simulink

조회 수: 6 (최근 30일)
Juraj Jakubov
Juraj Jakubov 2020년 10월 30일
답변: Anmol Dhiman 2020년 11월 9일
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