Vous êtes sur la page 1sur 5

Nama : Nafilah Insan Bestari

Kelas : 2C

11) x=[1:5]'; y=[0 14 44 96 176]';

>> p=polyfit(x,y,length(x)-1);

>> y1=polyval(p,[1:0.1:5]');

>> y2=interp1(x,y,[1:0.1:5]');[y1 y2]

ans =

0.0000 0

0.8510 1.4000

1.8080 2.8000

2.8770 4.2000

4.0640 5.6000

5.3750 7.0000

6.8160 8.4000

8.3930 9.8000

10.1120 11.2000

11.9790 12.6000

14.0000 14.0000

16.1810 17.0000

18.5280 20.0000

21.0470 23.0000

23.7440 26.0000

26.6250 29.0000

29.6960 32.0000
32.9630 35.0000

36.4320 38.0000

40.1090 41.0000

44.0000 44.0000

48.1110 49.2000

52.4480 54.4000

57.0170 59.6000

61.8240 64.8000

66.8750 70.0000

72.1760 75.2000

77.7330 80.4000

83.5520 85.6000

89.6390 90.8000

96.0000 96.0000

102.6410 104.0000

109.5680 112.0000

116.7870 120.0000

124.3040 128.0000

132.1250 136.0000

140.2560 144.0000

148.7030 152.0000

157.4720 160.0000

166.5690 168.0000

176.0000 176.0000
13) a) >> y=@(x) (2*x-3).^2-(x.^4+3)/(x.^2+1);

>> x=fzero(y,1)

x=

0.7756

b) >> x=fzero(@(x) y(x)-3,1)

x=

0.3000

c) >> x1=fzero(y,1);x2=fzero(y,10);

>> L=abs(quad(y,x1,x2))+quad(y,x2,7)-316;

>> f=@(a) abs(quad(y,a,x1))+L;fzero(f,-3)

ans =

-4.0002

d) >> f=@(a) quad(y,a,a+2)-316;a=fzero(f,10)

a=

8.2812
11. Cara lain

>> x=[1:5]'; y=[0 14 44 96 176]';

>> xi=[1:.1:5]';

>> abcde=[x.^4 x.^3 x.^2 x ones(size(x))]\y;

>> [polyval(abcde,xi) interp1(x,y,xi,'spline')]

ans =

0.0000 0

0.8510 0.8510

1.8080 1.8080

2.8770 2.8770

4.0640 4.0640

5.3750 5.3750

6.8160 6.8160

8.3930 8.3930

10.1120 10.1120

11.9790 11.9790

14.0000 14.0000

16.1810 16.1810

18.5280 18.5280

21.0470 21.0470

23.7440 23.7440

26.6250 26.6250

29.6960 29.6960

32.9630 32.9630

36.4320 36.4320

40.1090 40.1090
44.0000 44.0000

48.1110 48.1110

52.4480 52.4480

57.0170 57.0170

61.8240 61.8240

66.8750 66.8750

72.1760 72.1760

77.7330 77.7330

83.5520 83.5520

89.6390 89.6390

96.0000 96.0000

102.6410 102.6410

109.5680 109.5680

116.7870 116.7870

124.3040 124.3040

132.1250 132.1250

140.2560 140.2560

148.7030 148.7030

157.4720 157.4720

166.5690 166.5690

176.0000 176.0000