Matlab Lab 1
-
Upload
garrett-knapp -
Category
Documents
-
view
227 -
download
1
description
Transcript of Matlab Lab 1
Garrett KnappMat 275 Lab
W 1:30MAT 275 MATLAB Assingment #1
%Problem 1theta=linspace(0,5*pi/4,6); %Creates row vector for thetax=2*cos(theta); %Creates x-component for circley=2*sin(theta); %Creates y-compononent for circler=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 2e=2.718281828;t=linspace(1,10,91)output=((e^(0.1.*t))*sin(t'))/(t.^2+1)end
%Problem 3t=linspace(0,20,250); %Creating x,y, and z values as defined by problem statementx=sin(t);y=cos(t);z=t;plot3(x,y,z) %Plotting all variables in three dimensions
%Problem 4b=linspace(0,pi,2000);y=cos(b);z=1-(b.^2)/2+(b.^4)/24;plot(b,y,'r',b,z,'--')grid on
%Problem 5function ex5x=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+Cend