9) Appendix- Matlab Code

%Step 1- create a time matrix. I want to track this for 1 second
t=linspace(0,1,361);
%Step 2- find alpha
%use degrees/s^2
alpha = [zeros(1,361)];
%Step 3- find w
%degrees/second
w = [-360*ones(1,361)];
%Step 4- find theta
%use degrees
theta = [w.*t];

%Define delta and r
delta =linspace(1,360,360);
r = (3.7-1.5)*((delta/360)-(1/pi())*sin(pi()*delta/360))+1.5;

%Determine maximum height and plot schematic
figure
for i = 1:length(theta)
height = r.*(sind(delta+theta(:,i)));
width = r.*(cosd(delta+theta(:,i)));
[pheight(i,:),I(i,:)] = max(height);

plot(width,height,[-3.5 3.5 3.5 -3.5 -3.5],[pheight(i,:) pheight(i,:) (pheight(i,:)+.25) (pheight(i,:)+.25) pheight(i,:)],...
[-.5 .5 .5 -.5 -.5], [(pheight(i,:)+.25) (pheight(i,:)+.25) (pheight(i,:)+5.25) (pheight(i,:)+5.25) (pheight(i,:)+.25)])
axis([-9.45 9.45 -4 12])
pause(.005)
end

%Determine height and angle of the wing
deltaheight = pheight-min(pheight);
twing =atan2d((7.5+deltaheight-8.4),.85);
%Find angle of the feet
feetangle = asind(deltaheight/3);

%Plot
figure
subplot(1,3,1)
plot(t, deltaheight)
xlabel('Time')
ylabel('Penguin Height (cm)')
subplot(1,3,2)
plot(t,gradient(deltaheight)*360)
xlabel('Time')
ylabel('Penguin Velocity (cm/s)')
subplot(1,3,3)
plot(t,gradient(gradient(deltaheight)*360)*360)
xlabel('Time')
ylabel('Penguin Acceleration (cm/s^2)')

figure
subplot(1,3,1)
plot(t,twing)
xlabel('Time')
ylabel('Wing Angle (Degrees)')
subplot(1,3,2)
plot(t,gradient(twing)/.005)
xlabel('Time')
ylabel('Wing Angular Velocity (Degrees/s)')
subplot(1,3,3)
plot(t,gradient(gradient(twing)/.005)/.005)
xlabel('Time')
ylabel('Wing Angular Acceleration (Degrees/s^2)')

figure
subplot(1,3,1)
plot(t,feetangle)
xlabel('Time')
ylabel('Feet Angle (Degrees)')
subplot(1,3,2)
plot(t,gradient(feetangle)/.005)
xlabel('Time')
ylabel('Feet Angular Velocity (Degrees/s)')
subplot(1,3,3)
plot(t,gradient(gradient(feetangle)/.005)/.005)
xlabel('Time')
ylabel('Feet Angular Acceleration (Degrees/s^2)')