You are on page 1of 3

Garrett Knapp

Mat 275 Lab


W 1:30
MAT 275 MATLAB Assingment #1
%Problem 1
theta=linspace(0,5*pi/4,6); %Creates row vector for theta
x=2*cos(theta); %Creates x-component for circle
y=2*sin(theta); %Creates y-compononent for circle
r=sqrt(x.^2+y.^2) %Confirms x&y create circle, r=2 for all cases
%Problem 2
function ex2
%This function solves the function in excercise 2
e=2.718281828;
t=linspace(1,10,91)
output=((e^(0.1.*t))*sin(t'))/(t.^2+1)
end

%Problem 3
t=linspace(0,20,250); %Creating x,y, and z values as defined by problem
statement
x=sin(t);
y=cos(t);
z=t;
plot3(x,y,z) %Plotting all variables in three dimensions

%Problem 4
b=linspace(0,pi,2000);
y=cos(b);
z=1-(b.^2)/2+(b.^4)/24;
plot(b,y,'r',b,z,'--')
grid on

%Problem 5
function ex5
x=linspace(0,4,200);
y1=x.^2/2+2*x-1;
y2=x.^2/2+2*x;
y3=x.^2/2+2*x+1;
plot(x,y1,'-',x,y2,':',x,y3,'--')
title('Solutions to dy/dx=x+2')
legend('C=-1','C=0','C=1')
end
function y=f(x,C)
y=(x.^2)/2+2x+C
end