Contents

Aaron Klapheck

% Ch 5. Assignment #13       due 12/5
clear, clc
Date = date
Date =

12-Dec-2007

Problem 33

% Purpose
% The goal here is to find a function that best fits the given data.
% When this is done the data and the function will be plotted on the same
% coordinate axis.

% Given
% A copper sphere with diameter (d) and temperature (Temp).
% d = 25 mm
% Temp_initial = 300 degrees C
% Temp_final = approximately 0 degrees C

Time = [0:1:6];
Temp = [300, 150, 75, 35, 12, 5, 2];


% Try an expoential function. A power fucntion won't work because the log
% of 0 does not exist.

p = polyfit(Time, log10(Temp), 1);
m = p(1);
b = 10.^p(2);

x_2 = [0:0.01:6];
f_of_x = b.*(10).^(m.*x_2);

plot(Time, Temp, 'o', x_2, f_of_x), xlabel('Time (seconds)'), ...
    title('The Cooling of a Sphere Over Time'), ...
    ylabel('Temperature (degrees C)'), ...
    legend('Data', 'Approximating Function')

Problem 49

% Purpose
% The goal of this problem is to graph three 3D plots of a helix given as
% a function of x and y.
% When this is compleated a compairison will be made between the three
% plots.

% Given
% x = a*cos(t)
% y = a*sin(t)
% z = b*t
% a = 1
% 0 <= t <= 10*pi

a = 1;
t = [0:0.1:10*pi];

Problem 49 - Part a (b = 0.1)

b = 0.1;
x = a*cos(t);
y = a*sin(t);
z = b*t;

plot3(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), ...
    title('Helix when b = 0.1'), grid

Problem 49 - Part b (b = 0.2)

b = 0.2;
x = a*cos(t);
y = a*sin(t);
z = b*t;

plot3(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), ...
    title('Helix when b = 0.2'), grid

Problem 49 - Part c (b = -0.1)

b = -0.1;
x = a*cos(t);
y = a*sin(t);
z = b*t;

plot3(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), ...
    title('Helix when b = -0.1'), grid

% Comparison
% The plot in part b is stretched twice as long as in part a.
% The plot in part c is the same length as in part a but is going downward
% instead of upward.

Problem 50

% Purpose
% The goal of this problem is to obtain a 3D plot of a robot's hand while
% it moves through space and time.

% Given
% The location of a robot hand is given in a 3D coordinate system and is a
% funtion of time (in minutes).

t = [0:0.0001:0.2];
x = (0.5 + 5.*t).*sin((2*pi/3).*t).*cos(4*pi.*t); % checked on calculator
y = (0.5 + 5.*t).*sin((2*pi/3).*t).*sin(4*pi.*t);
z = (0.5 + 5.*t).*sin((2*pi/3).*t);

plot3(x, y, z), xlabel('x-coordinate'), ylabel('y-coordinate'), ...
    zlabel('z-coordinate'), title('Movement of a Robot Hand'), grid

Problem 52 - Mesh plot

% Purpose
% The goal of this problem is to obtian both a surface and a contour plot
% of a function z.
% After this, the identification of the contour line type coorosponding to
% a saddlepoint took place.

% Given
% z = -x^2 + 2xy + 3y^2

[x, y] = meshgrid(-10:0.1:10);
z = -x.^2 + 2.*x.*y + 3.*y.^2;

meshz(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), ...
    title('Meshz Plot')

Problem 52 - Surface plot

surf(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), ...
    title('Surface Plot')

Problem 52 - Contour plot

contour(x, y, z), xlabel('x'), ylabel('y'), zlabel('z'), ...
    title('Countour Plot'), grid

% The contour lines cross eachother at a sadel point .