How to extend a line plot and animate it?

5 次查看(过去 30 天)
I made a code for a four-bar mechanism, and for that I plot lines from Bx to Px and from By to Py in what I call an "elo", as you can see here:
Elo6 = plot([Bx(teta2) Px(teta2)],[By(teta2) Py(teta2)],'y',LineWidth=4); %This is the yellow line that connects the white dot to the red dot
Which gives me this (with a few extra elos and details):
However, I am simulating a mechanism for a garage door, and for that I need "Elo6" to be extandable a set amount for both of its ends just like in the following image (ignore the red dot outside):
The way I did this was by using some mechanism theory, but it only works for this especific case (I discovered and used coordinates for the two ends of the "door", just like in "Elo6"), I need a way to extend the elo so that if i change the rest of the mechanism, the "door" still works the same (Plotting independently from its ends coordinates).
I also made an animation of it by using a While True function and changing the values of "teta2", like this:
ii = teta2;
while 1
ii = ii+0.1
set(Elo6,'XData',[Bx(ii) Px(ii)]);
set(Elo6,'YData',[By(ii) Py(ii)]);
end
Would be nice if I could also animate the new door code using the same setup.

回答(0 个)

类别

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

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by