Está en la página 1de 4

M-FILE

function dy=runge(x,y)
dy=[y(2);x+(1-0.2*x)*y(1)];

MAT-LAB

>> [X Y]=ode45(@runge,[0:0.1:2],[0 0.5])

X =

0
0.1000
0.2000
0.3000
0.4000
0.5000
0.6000
0.7000
0.8000
0.9000
1.0000
1.1000
1.2000
1.3000
1.4000
1.5000
1.6000
1.7000
1.8000
1.9000
2.0000

Y =

0 0.5000
0.0502 0.5075
0.1020 0.5298
0.1567 0.5671
0.2159 0.6194
0.2811 0.6869
0.3538 0.7701
0.4356 0.8693
0.5282 0.9852
0.6333 1.1183
0.7525 1.2693
0.8877 1.4390
1.0409 1.6281
1.2140 1.8375
1.4091 2.0680
1.6284 2.3207
1.8740 2.5963
2.1484 2.8959
2.4540 3.2202
2.7933 3.5703
3.1690 3.9469
>> [X Y]=ode45(@runge,[0:0.1:2],[0 1.5])

X =

0
0.1000
0.2000
0.3000
0.4000
0.5000
0.6000
0.7000
0.8000
0.9000
1.0000
1.1000
1.2000
1.3000
1.4000
1.5000
1.6000
1.7000
1.8000
1.9000
2.0000

Y =

0 1.5000
0.1504 1.5124
0.3033 1.5494
0.4611 1.6106
0.6262 1.6961
0.8011 1.8059
0.9882 1.9404
1.1900 2.1000
1.4091 2.2853
1.6480 2.4970
1.9094 2.7358
2.1961 3.0028
2.5109 3.2988
2.8568 3.6248
3.2369 3.9819
3.6543 4.3713
4.1123 4.7939
4.6142 5.2509
5.1636 5.7433
5.7641 6.2722
6.4193 6.8383

>> [X Y]=ode45(@runge,[0:0.1:2],[0 -1.391])

X =

0
0.1000
0.2000
0.3000
0.4000
0.5000
0.6000
0.7000
0.8000
0.9000
1.0000
1.1000
1.2000
1.3000
1.4000
1.5000
1.6000
1.7000
1.8000
1.9000
2.0000

Y =

0 -1.3910
-0.1392 -1.3929
-0.2787 -1.3981
-0.4189 -1.4062
-0.5600 -1.4167
-0.7023 -1.4291
-0.8459 -1.4430
-0.9909 -1.4578
-1.1375 -1.4732
-1.2856 -1.4888
-1.4352 -1.5039
-1.5863 -1.5182
-1.7388 -1.5312
-1.8925 -1.5424
-2.0472 -1.5511
-2.2026 -1.5570
-2.3585 -1.5593
-2.5143 -1.5575
-2.6698 -1.5510
-2.8243 -1.5390
-2.9774 -1.5209

>> OTRO EJERCICIO

M-FILE

function dy=runge2(x,y)
dy=[y(1)-2*y(2);y(1)+y(2)*x];

MAT - LAB
>> [X Y]=ode45(@runge2,[0:0.1:0.5],[0 1.1845])

X =

0
0.1000
0.2000
0.3000
0.4000
0.5000

Y =

0 1.1845
-0.2487 1.1782
-0.5208 1.1574
-0.8154 1.1192
-1.1309 1.0602
-1.4647 0.9765
OTRA FORMA DE SOLUCIONAR

M-FILE1

function dydx=UNO(x,y)
dydx=[y(1)-2*y(2);y(1)+y(2)*x];

M-FILE2

function dydx=dos(ya,yb)
res=[ya(1);yb(1)+1.4647];

MAT- LAB

>> sol=bvpinit(linspace(0,0.5,5),[0.5 1])

sol =

x: [0 0.1250 0.2500 0.3750 0.5000]


y: [2x5 double]

CONTINUARA.......