1 / 7100%
Lab 1 - Nathan Florean - MAT 275
Table of Contents
Exercise 1 .......................................................................................................................... 1
Exercise 2 .......................................................................................................................... 1
Exercise 3 .......................................................................................................................... 4
Exercise 4 .......................................................................................................................... 4
Exercise 5 .......................................................................................................................... 5
Exercise 6 .......................................................................................................................... 6
Exercise 1
theta = [0 pi/3 pi/2 2*pi/3 pi 4*pi/3]; %radians
r = 3; %units
x = r*cos(theta);
y = r*sin(theta);
r = sqrt((x.^2) + (y.^2))
r =
3.0000 3.0000 3.0000 3.0000 3.0000 3.0000
This proves that x and y do satisfy the equation for a circle, because with every angle around the circle,
the radius remains the same.
Exercise 2
t = linspace(1,10,46);
e = exp(t/20);
c = cos(t);
den = (t.^2)+4;
num = e.*c;
y = num./den;
Part (a)
figure;
plot(t,y,'k-');
title('y');
1
Lab 1 - Nathan Florean - MAT 275
Part (b)
figure;
plot(t,y,'o');
title('y vs t')
figure;
plot(t,y,'o-');
title('y vs t')
2
y vs
t
al
0.15
0.1
7
0.05
7
~0.05
7
“0.1
10
yvst
0.15
Lab 1 - Nathan Florean - MAT 275
3
Lab 1 - Nathan Florean - MAT 275
Exercise 3
t = linspace(0,30,300);
x = sin(t);
y = cos(t);
z = t;
figure;
plot3(x,y,z);
grid on;
Exercise 4
x = linspace(-pi,pi,100);
y = sin(x);
z = x-((x.^3)/6)+((x.^5)/120);
figure;
plot(x,y,'r',x,z,'--');
axis tight;
grid on;
4
Lab 1 - Nathan Florean - MAT 275
Exercise 5
type 'ex5.m'
run 'ex5.m'
function ex5
x = linspace(0,5,50) ;
y1 = f(x,-2);
y2 = f(x,0);
y3 = f(x,2);
plot(x,y1,'r-',x,y2,'b--',x,y3,'g.')
title('Solutions to dy/dx = x^2 -2x')
legend('C = -2','C = 0', 'C = 2','Location','northwest')
end
function y = f(x,C)
y = ((x.^3)/3)-(x.^2)+C;
end
5
Lab 1 - Nathan Florean - MAT 275
Exercise 6
Part (a)
f = @(x,y)(x.^2)+((x*(exp(y))/(y+1)));
x=-1
y=2
f(-1,2)
x =
-1
y =
2
ans =
-1.4630
Part (b)
6
Lab 1 - Nathan Florean - MAT 275
clear f
type 'f.m'
function f
f = @(x,y)(x .^2 + (x*(exp(y)))/(y + 1))
x=-1
y=2
end
Published with MATLAB® R2017b
7
Powered by TCPDF (www.tcpdf.org)
Students also viewed