Você está na página 1de 6

# LAB FOR MATLAB

1.
>> syms x; f=0.1*x.^3-x.^2+2*x+1
f=
x^3/10 - x^2 + 2*x + 1
>> int(f,x,-1,2)
ans =
27/8

2.
int((2*x^2 + 1) * sin(x), x, 0, pi)
2*pi^2 - 6
ans =
2*pi^2 - 6
ans =
13.7392

3.
f1=3*x-x^2;
f2=x-3;
r=roots(sym2poly(f1-f2));
int(f1,x,r(2),r(1))-int(f2,x,r(2),r(1))
ans =
32/3

4.
x=-2:0.5:5;
y=[23 19.25 16 13.25 11 9.25 8 7.25 7 7.25 8 9.25 11 13.25 16];
area=trapz(x,y)

area =
79.6250

5.
t = 0:0.005:5;
x = sin(3*t)./(1 + t.^2);
plot(t,x)
displacement vs. time
x = sin(3t)/(1 + t 2)
1

0.8

displacement x(t)

0.6

0.4

0.2

-0.2

-0.4

0.5

6.
>> syms t; f=sin(3*t)./(1 + t.^2);

1.5

2.5
time, s

3.5

4.5

>> dx=diff(f)
>> ezplot(dx,0,5);
ans =
(3*cos(3*t))/(t^2 + 1) - (2*t*sin(3*t))/(t^2 + 1)^2

## (3 cos(3 t))/(t2 + 1) - (2 t sin(3 t))/(t2 + 1)2

2
1.5
1

v(t)

0.5
0
-0.5
-1
-1.5

7.
>> dx2=diff(f,2)
>> ezplot(dx2,0,5)

0.5

1.5

2.5
t

3.5

4.5

dx2 =
(8*t^2*sin(3*t))/(t^2 + 1)^3 - (2*sin(3*t))/(t^2 + 1)^2 - (9*sin(3*t))/(t^2 + 1) - (12*t*cos(3*t))/(t^2 +
1)^2
(8 t2 sin(3 t))/(t2 + 1)3 -...- (12 t cos(3 t))/(t2 + 1)2
4

a(t)

-2

-4

-6

-8
0

0.5

8.
for i=0:100;
series100=1/i;
end
series100
for i=0:1000;
series1000=1/i;
end
series1000
for i=0:10000;
series10000=1/i;
end
series10000

>> lab13
series100 =

1.5

2.5
t

3.5

4.5

0.0100
series1000 =
1.0000e-003
series10000 =
1.0000e-004
Yes, they tend towards zero.

9.
function a=sumrec2(n)
for n=0:m;
a=1/n.^2
end;

## Yes, the number tends towards zero.

10.
for n=1:40;
series1=(-1)^n/(n+1);
end
series1

>> lab13
series1 =
0.0244

11.
area=0;
r=0;
while area < 15000;
r=r+1

area=pi*r^2;
end

r=
70

12.
volume=0;
r=0;
while volume < 15000;
r=r+1
volume=(4*pi*r^3)/3;
end

r=
15

13.
f1=inline('x^2');
f2=inline('x');
x=[-2,0,0.5,2,5];
y=zeros(size(x));
for n=1:length(x);
if x(n) <= 0 y(n)=f1(x(n));
end;
if x(n)> 0 y(n)= f2(x(n));
end;
end;
y