Write a computer program to reproduce this figure FIGURE 818
Solution
theta = [0:pi/10000:1];
% simple harmonic motion
a = (pi^2/2).*cos(pi.*theta);
plot(theta,a)
% cycloid
ac = 2*pi*sin(2*pi.*theta);
hold on
plot(theta,ac,\'m\')
xlabel(\'Theta\');
ylabel(\'Acceleration\');
% constant acceleration
for i = 1:length(theta)
if theta(i)<=1/2
acn(i) = 4;
else
acn(i) = -4;
end
end
plot(theta,acn,\'k\')
% modified trapezoid
for i = 1:length(theta)
if theta(i)<1/8
act(i) = 4.89.*sin(4*pi.*theta(i));
elseif theta(i)>1/8 && theta(i)<3/8
act(i) = 4.89;
elseif theta(i)>3/8 && theta(i)<4/8
act(i) = -4.89.*sin(4*pi.*theta(i));
elseif theta(i)>4/8 && theta(i)<5/8
act(i) = -4.89.*sin(4*pi.*theta(i));
elseif theta(i)>5/8 && theta(i)<7/8
act(i) = -4.89;
elseif theta(i)>7/8 && theta(i)<1
act(i) = 4.89.*sin(4*pi.*theta(i));
end
end
plot(theta,act,\'r\')
% modified sine
for i = 1:length(theta)
if theta(i)<1/8
acs(i) = 5.53.*sin(4*pi.*theta(i));
elseif theta(i)>1/8 && theta(i)<7/8
acs(i) = 5.53*sin((4*pi/3)*theta(i)+(pi/3));
else
acs(i) = 5.53.*sin(4*pi.*theta(i));
end
end
plot(theta,acs,\'g\')
thank you.
