You are on page 1of 5

Oprator 1 matlab hal 42

>> y=@(x)100*(x(2)-x(1).^2).^2+(1-x(1)).^2;

>> tebakan=(1 3)

>> tebakan=[1 3];

>> fminsearch(y,tebakan)

ans =

1.0000 1.0000

>> y(ans)

Pers diferensial nilai awal hal 47-52

>> pd=@(x,y)x.^2+2.*x+1-y;

>> x0=0;y0=1;

>> xspan=[x0 1 2 5 6];

>> [x,y]=ode45(pd,xspan,y0]

??? [x,y]=ode45(pd,xspan,y0]

Error: Unbalanced or misused parentheses or brackets.

>> [x,y]=ode45(pd,xspan,y0)

x=
0

y=

1.0000

1.9999

4.9999

26.0000

37.0001

>> [x y]

ans =

0 1.0000

1.0000 1.9999

2.0000 4.9999

5.0000 26.0000

6.0000 37.0001

>> pd=@(x,y)y-x.^3+3.*x.^2+2.*x-4;

>> x0=0;y0=2;

>> xspan=[x0 1 3 6 9];


>> [x,y]=ode45(pd,xspan,y0)

x=

y=

2.0000

1.0001

23.0032

206.0819

714.6197

>> [x y]

ans =

0 2.0000

1.0000 1.0001

3.0000 23.0032

6.0000 206.0819

9.0000 714.6197
ans =

6.6502e-010

>> y([3 3])

ans =

3604

>> y([2 1])

ans =

901

>> y([0.5 1])

ans =

56.5000

>> y([1 1])

ans =

>> y([-2 10])


ans =

3609