1 / 3100%
MAT 275 MATLAB LAB 1
Exercise 1
r=2;
theta=[0, pi/4, pi/2, 3*pi/4, pi, 5*pi/4];
x=r*cos(theta);
y=r*sin(theta);
r1=sqrt(x.^2+y.^2)
r1 =
2 2 2 2 2 2
Exercise 2
(a)
t=linspace(1,10,91);
y=exp(t/10).*sin(t)./(t.^2+1);
title('e^{t/10}sin(t)/(t^{2}+1)');
plot(t,y,'k');
(b)
>> t=linspace(1,10,91);
y=exp(t/10).*sin(t)./(t.^2+1);
plot(t,y,'o');
title('e^{t/10}sin(t)/(t^{2}+1)');
NAME:Jianyang Hu
LAB DAY AND TIME:
INSTRCTOR: Vandana Sharma
Exercise 3
t=linspace(0,20);
x=sin(t);
y=cos(t);
z=t;
plot3(x,y,z);
xlabel('x');
ylabel('y');
zlabel('z');
Exercise 4
grid on;
x=linspace(0,pi);
y=cos(x);
z=1-x.^2/2+x.^4/24;
plot(x,y,'r',x,z,'--');
Exercise 5
% structure function+function
function y=f(x,C)
y=x.^2/2+2*x+C;
end
%m file
function ex5
x=linspace(0,4);
y1=x.^2/2+2*x+(-1);
y2=x.^2/2+2*x+0;
y3=x.^2/2+2*x+1;
plot(x,y1,x,y2,'--r',x,y3,'.b')
title('Solution of the differential equation');
legend('C= -1','C= 0','C= 1');
end
Exercise 6
f=inline('x^3+y*exp(x)/(x+1)','x','y');
f(2,-1)
ans =
5.5370
b)
function f(x,y)
f=x^3+y*exp(x)/(x+1)
end
f(2,-1)
f =
5.5370
Powered by TCPDF (www.tcpdf.org)
Students also viewed