1
Table of Contents
>> Matt Seelig; Mon 9:00 - 9:50 ........................................................................................... 1
Problem 2 .......................................................................................................................... 2
a) ...................................................................................................................................... 2
b) ..................................................................................................................................... 3
Problem 3 .......................................................................................................................... 4
Problem 4 .......................................................................................................................... 5
Problem 5 .......................................................................................................................... 6
Problem 6 .......................................................................................................................... 7
>> Matt Seelig; Mon 9:00 - 9:50
%%Problem 1 %% theta = [0, 2*pi, ]
theta = 0:.1:2*pi; 1 %% theta = [0, 2*pi, ]
r =3;
x = r*cos(theta);
y = r*sin(theta);
T = sqrt(x.^2 + y.^2)
ans =
1
T =
Columns 1 through 7
3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000
Columns 8 through 14
3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000
Columns 15 through 21
3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000
Columns 22 through 28
3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000
Columns 29 through 35
3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000
Columns 36 through 42
3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000
2
Columns 43 through 49
3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000
Columns 50 through 56
3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000
Columns 57 through 63
3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000
Problem 2
t = 1: .2: 10;
y = (exp(t/20).*cos(t))./(t.^2 + 4);
a)
figure(1)
plot(t,y, '-ko') %%creates plot with linespec black solid line w/ o
marker
title('(exp(t/20).*cos(t))./(t.^2 + 4)')
3
b)
figure(2)
plot(t,y, 'o')
figure(3)
plot(t,y, 'o-')
4
Problem 3
t = 0:.1:30;
x = sin(t);
y = cos(t);
z = t;
figure(4)
plot3(x,y,z, 'k')
grid on
title('Circular Helix')
5
Problem 4
x = -pi: pi/24: pi;
y = sin(x);
z = x - (x.^3)/3 + (x.^5)/5;
figure(5)
plot(x,y, 'm',x,z,'b')
grid on
axis tight
6
Problem 5
x = 0: .1 : 5;
y1 = ex5(x,-2);
y2 = ex5(x, 0);
y3 = ex5(x, 2);
figure(6)
plot(x, y1, 'k-', x, y2, 'b-', x, y3, 'c-')
axis tight
grid on
title('Solutions to dy/dx = x .^2 + 2x')
legend('C = -2', 'C = 0', 'C = 2')
type ex5
function [ y ] = ex5(x, C)
%Function file accepting x, C
% answer to dy/dx = x^2 + 2x with initial condition stated
y = (x.^3)/3 + x.^2 + C;
end
7
Problem 6
%%a)
f = inline('(x.^2 + (x.*exp(y)./(y+1)))', 'x', 'y');
f(-1, 2) %% inputs arguments x = -1 y = 2
%%b)
clear f
F = f(-1,2)
type f
ans =
-1.4630
F =
-1.4630
function [ y ] = f( x, y )
%function containing x and y