How to create a time function and make a line rotate at a certain angular speed?
Show older comments
Hello! I have a question regarding my code I am trying to make an animation of a four bar linkage but in the end I need to plot theta_2 vs time. Angular speed should be 1 rad/sec, but I'm having trouble trying to wrap my head around the concept of time in MATLAB. How could I make the line rotate at a certain angular speed and how would I plot a graph of theta vs time? Any insight would be appreciated! Thanks!
r2_length = 2;
theta_2 = 0:0.1:2*pi;
y_r2 = r2_length * sin(theta_2);
x_r2 = r2_length * cos(theta_2);
origin = [0,0];
for i = 1:length(theta_2)
r2 = line([origin(1) x_r2(i)], [origin(2) y_r2(i)],'linewidth', 2);
hold on
axis([-10 10, -10 10]);
grid on
pause(0.001);
if i ~= length(theta_2)
clf
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!