Question: URGENT: NEED HELP WITH MATLAB CODE This is my code for MATLAB for simulating the motion of a swing: x = [-1 , 1, 1,
URGENT: NEED HELP WITH MATLAB CODE
This is my code for MATLAB for simulating the motion of a swing:
x = [-1 , 1, 1, 1,-1 ];
y = [-1/3,-1/3, 0, 1/3, 1/3];
g = hgtransform;
patch('XData',x,'YData',y,'FaceColor','black','Parent',g)
axis equal
xlim([-11 11])
ylim([-11 11])
xs = linspace(-10,10,100);
ys = 10*cos(xs);
ampx = 8;
ampy = 6;
w = 1;
phi = 0;
damp = .01;
e = exp(1);
et = (e^(-damp*t));
for t=linspace(0,28*pi/2,5600)
g.Matrix = makehgtform('translate',-ampx*et*cos(w*t+phi),-ampy*et*((sin(w*t+phi))^2),0);
drawnow
end
I NEED TO ADD 2 things:
1. a vertical line at each end of the swing, to act as the cords
2. I need to get the swing to slow down and come to a stop over time like a normal swing would,
but the swing should continue to stay on the same arc (also like a normal swing does)
please help!
x 3 [-1 1, 1, 1,-1 y 1/3 0, 1/3 1/3] g hgtrans form patch XData YData y Face Color black Parent g) axis equal x lim [-11 11]) ylim( [-11 11]) xs 3 linspace (-10, 10, 100) ys 10*cos (xs) ampx ampy phi 30;I damp 01 e 3 exp (1) et 3 (e (-damp*t)) for t linspace (0,28*pi/2,5600) g.Matrix 3 makehgt form translate et cos (w*t+phi) ampyxetxa (sin (wxt +phi)) 2) ,0); drawnow end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
