Matlab - Por qué sale esto "" debe ser un número entero positivo o lógica.""

 
Vista:

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
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

Por qué sale esto "" debe ser un número entero positivo o lógica.""

Publicado por Álvaro (20 intervenciones) el 13/11/2014 23:01:21
Hola Amalia

Pienso que si dices en que línea estás teniendo el problema será más fácil que se te pueda responder.

Un saludo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Por qué sale esto "" debe ser un número entero positivo o lógica.""

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 14/11/2014 00:56:00
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
54
55
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;
f=inline(f);
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,w+1932/2197*k1-7200/2197*k2+7296/2197*k3);
    k5=h*f(t+h, w +439/216*k1-8*k2+3680/513*k3-845/4104*k4-11/40*k4);
    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))
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)
    return;
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
end

Saludos.
JOSE JEREMÍAS CABALLERO
Asesoría online y Presencial en Matlab
programador en matlab
Servicios de programación matlab
[email protected]
Estimado Usuario de Matlab, el correo es para servicios de cursos, asesoría y programación. Toda ayuda gratuita es vía foro.


http://matlabcaballero.blogspot.com

http://www.lawebdelprogramador.com/foros/Matlab/1371532-FORMA_DE_APRENDER_MATLAB.html
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Por qué sale esto "" debe ser un número entero positivo o lógica.""

Publicado por Amalia (2 intervenciones) el 15/11/2014 05:09:07
Muchas gracias Álvaro y Prof. Caballero
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar