Está en la página 1de 8

DESARROLLO DEL EJERCICIO 5

Nombre: Mabel Beatriz García Dávila


>> EJERCICIO 5

>> f1=inline('-0.1*x+0.02*x*y')

f1 =

Inline function:

f1(x,y) = -0.1*x+0.02*x*y

>> f2=inline('0.2*y-0.025*x*y')

f2 =

Inline function:

f2(x,y) = 0.2*y-0.025*x*y

>> w1=6; x0=6, n1=6; y0=6; h=0.2

x0 =

h=

0.200000000000000

>> k11=f1(w1,n1)

k11 =

0.120000000000000

>> k12=f2(w1,n1)

k12 =

0.300000000000000

>> k21=f1(w1+k11*h*0.5,n1+k12*h*0.5)

k21 =

0.123847200000000

>> k22=f2(w1+k11*h*0.5,n1+k12*h*0.5)

k22 =

0.299691000000000

>> k31=f1(w1+k21*h*0.5,n1+k22*h*0.5)

k31 =

0.123851409578243

1
>> k32=f2(w1+k21*h*0.5,n1+k22*h*0.5)

k32 =

0.299631468027196

>> k41=f1(w1+k31*h,n1+k32*h)

k41 =

0.127716248694701

>> k42=f2(w1+k31*h,n1+k32*h)

k42 =

0.299243662613256

>> w2=w1+(1/6)*(k11+2*k21+2*k31+k41)*h

w2 =

6.024770448928373

>> n2=n1+(1/6)*(k12+2*k22+2*k32+k42)*h

n2 =

6.059929619955589

>> %segunda iteracion para t=0.4 y h=0.4

>> h=0.4

h=

0.400000000000000

>> k11=f1(w2,n2)

k11 =

0.127716653045046

>> k12=f2(w2,n2)

k12 =

0.299243801568763

>> k21=f1(w2+k11*h*0.5,n2+k12*h*0.5)

k21 =

0.135500211283433

>> k22=f2(w2+k11*h*0.5,n2+k12*h*0.5)

k22 =

0.298291189507404

2
>> k31=f1(w2+k21*h*0.5,n2+k22*h*0.5)

k31 =

0.135512014385086

>> k32=f2(w2+k21*h*0.5,n2+k22*h*0.5)

k32 =

0.298043742191924

>> k41=f1(w2+k31*h,n2+k32*h)

k41 =

0.143360122897080

>> k42=f2(w2+k31*h,n2+k32*h)

k42 =

0.296757362909820

>> w3=w2+(1/6)*(k11+2*k21+2*k31+k41)*h

w3 =

6.078977197413651

>> n3=n2+(1/6)*(k12+2*k22+2*k32+k42)*h

n3 =

6.179174355147405

>> %TERCERA ITERACION t=0.6 y h=0.6

>> h=0.6

h=

0.600000000000000

>> k11=f1(w3,n3)

k11 =

0.143363480334320

>> k12=f2(w3,n3)

k12 =

0.296758370934874

>> k21=f1(w3+k11*h*0.5,n3+k12*h*0.5)

k21 =

0.155278287554674

3
>> k22=f2(w3+k11*h*0.5,n3+k12*h*0.5)

k22 =

0.294294233652987

>> k31=f1(w3+k21*h*0.5,n3+k22*h*0.5)

k31 =

0.155278384504485

>> k32=f2(w3+k21*h*0.5,n3+k22*h*0.5)

k32 =

0.293699458958047

>> k41=f1(w3+k31*h,n3+k32*h)

k41 =

0.167313748846223

>> k42=f2(w3+k31*h,n3+k32*h)

k42 =

0.290418591532125

>> w4=w3+(1/6)*(k11+2*k21+2*k31+k41)*h

w4 =

6.172156254743537

>> n4=n3+(1/6)*(k12+2*k22+2*k32+k42)*h

n4 =

6.355490789916312

>> %CUARTA ITERACION con t=0.8 y h=0.8

>> h=0.8

h=

0.800000000000000

>> k11=f1(w4,n4)

k11 =

0.167326019144584

>> k12=f2(w4,n4)

k12 =

0.290421102209590

4
>> k21=f1(w4+k11*h*0.5,n4+k12*h*0.5)

k21 =

0.183636189569701

>> k22=f2(w4+k11*h*0.5,n4+k12*h*0.5)

k22 =

0.284900776397732

>> k31=f1(w4+k21*h*0.5,n4+k22*h*0.5)

k31 =

0.183552391223583

>> k32=f2(w4+k21*h*0.5,n4+k22*h*0.5)

k32 =

0.283748389744175

>> k41=f1(w4+k31*h,n4+k32*h)

k41 =

0.199994965235117

>> k42=f2(w4+k31*h,n4+k32*h)

k42 =

0.276629422833133

>> w5=w4+(1/6)*(k11+2*k21+2*k31+k41)*h

w5 =

6.319049340872373

>> n5=n4+(1/6)*(k12+2*k22+2*k32+k42)*h

n5 =

6.582737304226517

>> %QUINTA ITERACION con t=1 y h=1

>> h=1

h=

>> k11=f1(w5,n5)

k11 =

0.200027902380934

5
>> k12=f2(w5,n5)

k12 =

0.276631415260089

>> k21=f1(w5+k11*h*0.5,n5+k12*h*0.5)

k21 =

0.220950964242053

>> k22=f2(w5+k11*h*0.5,n5+k12*h*0.5)

k22 =

0.265638985560891

>> k31=f1(w5+k21*h*0.5,n5+k22*h*0.5)

k31 =

0.220604300232226

>> k32=f2(w5+k21*h*0.5,n5+k22*h*0.5)

k32 =

0.263665381236935

>> k41=f1(w5+k31*h,n5+k32*h)

k41 =

0.241496680898727

>> k42=f2(w5+k31*h,n5+k32*h)

k42 =

0.249952980831206

>> w6=w5+(1/6)*(k11+2*k21+2*k31+k41)*h

w6 =

6.539821859577076

>> n6=n5+(1/6)*(k12+2*k22+2*k32+k42)*h

n6 =

6.846936159174342

6
i t wi ni
2 0.2 6.024770448928373 6.059929619955589
3 0.4 6.078977197413651 6.179174355147405
4 0.6 6.172156254743537 6.355490789916312
5 0.8 6.319049340872373 6.582737304226517
6 1.0 6.539821859577076 6.846936159174342

Graficamos

Para ello definimos los vectores

>> w=[w1 w2 w3 w4 w5 w6]

w=

Columns 1 through 4

6.000000000000000 6.024770448928373 6.078977197413651 6.172156254743537

Columns 5 through 6

6.319049340872373 6.539821859577076

>> n=[n1 n2 n3 n4 n5 n6]

n=

Columns 1 through 4

6.000000000000000 6.059929619955589 6.179174355147405 6.355490789916312

Columns 5 through 6

6.582737304226517 6.846936159174342

>> t=[0 0.2 0.4 0.6 0.8 1]

t=

Columns 1 through 4

0 0.200000000000000 0.400000000000000 0.600000000000000

Columns 5 through 6

0.800000000000000 1.000000000000000

plot(t,w, 'o-',t,n,'o-')

7
Como podemos ver la línea roja es la de presas que esta dado en miles y la línea azul es la de
depredadores, por lo que podemos ver siempre la cantidad de presas es mayor a la cantidad
de depredadores.

También podría gustarte