PLEASE HELP: MY MATLAB CODE STILL ISNT WORKING THIS IS MY CODE: x = [-1 , 1, 1,
ID: 3811412 • Letter: P
Question
PLEASE HELP: MY MATLAB CODE STILL ISNT WORKING
THIS IS MY CODE:
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 = .05;
e = exp(1);
e(t) = (e^(-damp*t));
for t=linspace(0,28*pi/2,5600)
g.Matrix = makehgtform('translate',-ampx*e(t)*cos(w*t+phi),-ampy*et*((sin(w*t+phi))^2),0);
drawnow
pause(.0001) % putting this statement will make you feel that .. swinging like a cradle in movie, it will slow down the plotting
line([0 0], [-11 11]); % this will give vertical lone between points which can acts as cords
line([-11 11], [-11 11]); % right side vertical line
end
I NEED TO ADD 3 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
3. MY SWING DOESNT MOVE ANYMORE. NOT SURE WHAT HAPPENED
please...all help appreciated!
x 3 [-1 1, 1, 1,-1 j y 1/3 0, 1/3, 1/3] g hgtrans form patch XData YData y Face Color black Parent ',g) axis equal xlim [-11 11]) ylim [-11 11]) xs linspace (-10, 10, 100) ys 10*cos (xs) ampx ampy 6; phi 0; dam 05 e J exp (1) e(t) (e (-damp*t)); for t linspace (0,28xpi/2,5600) g.Matrix J makehgt form translate ampx*e (t)*cos (wxt +phi) ampyxetxa (sin (w*t+phi) 2), 0); drawnow pause .0001) putting this statement will make you feel that swinging like a cradle in movie line (10 01, [-11 11]) this will give vertical lone between points which can acts as cords line [-11 11], [-11 11]) right side vertical line endExplanation / Answer
For the above program:
1. Adding a vertical line at each of the swing
simple command is line([x x], [y1 y2])
x= -1: .0001:1; %// Time values, were the swing stop at this time inreval //
ystart = [ -1/3 -1/3];
yend=[1/3 1/3];
figure; hold on;
for idx= 1 : nume1(ystart)
plot([ (idx) (idx)], ystart(idx) yend(idx)]);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.