How to make ball move in simulink

4 Ansichten (letzte 30 Tage)
Juraj Jakubov
Juraj Jakubov am 30 Okt. 2020
Beantwortet: Anmol Dhiman am 9 Nov. 2020
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.

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by