Matlab Lab 1
Matlab Lab 1
Matlab Lab 1
%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