Por qué sale esto "" debe ser un número entero positivo o lógica.""
Publicado por Amalia (2 intervenciones) el 13/11/2014 15:33:46
Hola, este es mi algoritmo de runge kutta fehlberg, a la hora de correrlo sale el comentario ''debe ser un número entero positivo o lógica'', aquí les muestro mi algoritmo; les agradecería me mostraran mis errores, gracias.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
clear all
f=input('ingrese la funcion ff(t,y):','s');
a=input('ingrese el extremo a:');
b=input('ingrese el extremo b:');
y0=input('ingrese la condicion inicial y0:');
TOL=input('ingrese la tolerancia:');
hmax=input('ingrese tamaño maximo:');
hmin=input('ingrese tamaño minimo:');
fprintf(' \n ')
fprintf(' ti ');
fprintf(' yi=y(i) ');
fprintf(' wi ');
t=a;
w=y0;
h=hmax;
BAND=1;
while (BAND)
k1=h.*f(t,w);
k2=h.*f(t+1/4*h,w+1/4*k1);
k3=h.*f(t+3/8*h,w+3/32*k1+9/32*k2);
k4=h.*f(t+12/13*h,wi+1932/2197*k1-7200/2197*k2+7296/2197*k3);
k5=h.*f(t+h, wi +439/216*k1-8*k2+3680/513*k3-845/4104*k4-11/40*k5);
k6=h.*f(t+1/2*h,w-8/27*k1+2*k2-3544/2565*k3+1859/4101*k4-11/40*k5);
R=(1/h).*abs(1/360*k1-128/4275*k3-2197/75240*k4+1/50*k5+2/55*k6);
%R=(1/h).*abs(w(i+1)-W(i+1))
end
if(R<=TOL),
t=t+h;
w=w+25/216.*k1+1408/2565.*k3+2197/4104.*k4-1/5.*k5;
fprintf(' %d ',t,w,h)
end
d=0.84*(TOL/R).^(1/4);
if(d<=0.1),
h=0.1*h;
if(d>=4),
h=4.*h;
else
h=d.*h;
end
end
if(h>hmax)
h=hmax;
end
if(t>=b)
BAND=0;
if(t+h>b)
h=b-t;
if(h<hmin)
BAND=0;
fprintf('%d',hmin)
end
end
end
Valora esta pregunta


0