How to make ball move in simulink

10 ビュー (過去 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 Center および File ExchangeSimulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by