LAB 1 - MAT 275 Exercise 1
Define input variable theta as discretized row vector (i.e.
array)
theta =[0 pi./8 pi./6 pi./5 6*pi./5 7*pi./6 8*pi./7];
Define radius
r=7;
Define x and y in terms of theta and r
x= r*cos(theta);
y= r*sin(theta);
r=sqrt(x.^2+y.^2)
r = 1×7
7.0000 7.0000 7.0000 7.0000 7.0000 7.0000 7.0000
Exercise 2
Define t-vector
t= linspace(1,10,100);
Define y-vector
y= (exp(t/10).*cos(2*t))./(0.8*t.^3+11);
Part (a)
Plot results (should have 3 plots total)
figure;
plot(t,y,'k');
title('exp(t/10).*cos(2*t))./(0.8*t.^3+11)');
Part (b)
Plot results as data points only and as data points with line.
figure %creates another figure window
plot(t,y,'k',t,y,'o-');
title('exp(t/10).*cos(2*t))./(0.8*t.^3+11');
Exercise 3
Create t-vector (choose enough elements so that plot is smooth!)
t = linspace(0,20,100);
Define x, y, x components in terms of t
x = 3*cos(7*t);
y = 3*sin(7*t);
z = 2*t;
Plot results
figure;
plot3(x,y,z);
xlabel('X');
ylabel('Y');
zlabel('Z');
Exercise 4
Define input variable as vector
x = linspace(0,pi);
Define y and z
y = sin(5*x);
z = 5*x-(125/6)*x.^3;
Plot results
figure;
plot(x,y,'r',x,z,'--');
axis tight;
grid on;
Exercise 5
type ex5.m
Run your M-file--i.e. execute the M-file
run 'ex5.m' % Was unable to run
Exercise 6
Part (a)
Define g as anonymous function
g=@(x,y)((x.^2)/(y.^3)+(cos(6*x*exp((2*y))/((x.^5)+7))));
Evaluate g at the given values of x and y
g(2,-5)
ans = 0.9680
Part (b)
Clear the function g out of the workspace