How to extend a line plot and animate it?

3 views (last 30 days)
Pedro
Pedro on 26 Nov 2023
Commented: Daniel on 26 Nov 2023
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.
  2 Comments
Daniel
Daniel on 26 Nov 2023
The setup you're using now looks like what I do when I want to create animated things. What breaks?

Sign in to comment.

Answers (0)

Categories

Find more on Animation in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!