Matlab - Error using mupadmex Error in MuPAD command: DOUBLE cannot convert the input expression into a doubl

   
Vista:

Error using mupadmex Error in MuPAD command: DOUBLE cannot convert the input expression into a doubl

Publicado por Pablo (3 intervenciones) el 14/11/2015 21:52:02
Hola, soy nuevo en esto y tengo el siguiente error
Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.

If the input expression contains a symbolic variable, use the VPA function instead.

Error in sym/double (line 936)
Xstr = mupadmex('symobj::double', S.s, 0);

Error in sym>privformatscalar (line 2707)
x = double(x);

Error in sym>privformat (line 2692)
s = privformatscalar(x);

Error in sym/subsasgn (line 1462)
[inds{k},refs{k}] = privformat(inds{k});

Error in aitken (line 3)
f(x) = (1/2)*(x + 2/x) ; %The function that find the next element in the sequence

Mi código es para el método delta cuadrado de Aitken, y es el siguiente
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
%These choices depend on the problem being solved
x0=1;                     %The initial value
f(x) = (1/2)*(x + 2/x) ;    %The function that find the next element in the sequence
tolerance = 10^-10 ;        %10 digit accuracy is desired
epsilon = 10^-16   ;        %Don't want to divide by a number smaller than this
 
maxIterations = 20  ;       %Don't allow the iterations to continue indefinitely
haveWeFoundSolution = false;%Were we able to find the solution to the desired tolerance? not yet.
 
for i = 1 : maxIterations
    x1 = f(x0);
    x2 = f(x1);
 
    lambda = absoluteValue((x2 - x1)/(x1 - x0));      %OPTIONAL: computes an approximation of |f'(fixedPoint)|, which is denoted by lambda
 
    denominator = x2 - 2*x1 + x0;
 
    if(absoluteValue(denominator) < epsilon)          %Don't want to divide by too small of a number
        print('WARNING: denominator is too small')
        break;                                        %Leave the loop
    end
 
    aitkenX = x2 - ( (x2 - x1)^2 )/(denominator);
 
    if(absoluteValue(aitkenX - x2) < tolerance)       %If the result is within tolerance
        print('The fixed point is', aitkenX)        %Display the result of the Aitken extrapolation
        haveWeFoundSolution = true;
        break;                                        %Done, so leave the loop
    end
 
 
    x0 = aitkenX;                                     %Update x0 to start again                  
 
end
 
if(haveWeFoundSolution == false)   %If we weren't able to find a solution to within the desired tolerance
    print('Warning: Not able to find solution to within the desired tolerance of ', tolerance);
    print('"The last computed extrapolate was ', aitkenX)
end

Que debo hacer para que funcione??
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
información
Otras secciones de LWP con contenido de Matlab
- Código fuente de Matlab
- Cursos de Matlab
- Temas de Matlab
- Chat de Matlab
información
Códigos de Matlab
- DÍAS DE LA SEMANA
- Fuerzas de Coulomb
- Fixed Pivot
Imágen de perfil de JOSE JEREMIAS CABALLERO

Error using mupadmex Error in MuPAD command: DOUBLE cannot convert the input expression into a doubl

Publicado por JOSE JEREMIAS CABALLERO jjcc94@hotmail.com (3432 intervenciones) el 15/11/2015 00:00:25
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
% Mi código es para el método delta cuadrado de Aitken, y es el siguiente
 %These choices depend on the problem being solved
 clc
 clear all
 syms x
 x0=1; %The initial value
 f(x) = (1/2)*(x + 2/x) ; %The function that find the next element in the sequence
 tolerance = 10^-10 ; %10 digit accuracy is desired
 epsilon = 10^-16 ; %Don't want to divide by a number smaller than this
 
 maxIterations = 20 ; %Don't allow the iterations to continue indefinitely
 haveWeFoundSolution = false;%Were we able to find the solution to the desired tolerance? not yet.
 
 for i = 1 : maxIterations
 x1 = f(x0);
 x2 = f(x1);
 
 lambda = abs((x2 - x1)/(x1 - x0)); %OPTIONAL: computes an approximation of |f'(fixedPoint)|, which is denoted by lambda
 
 denominator = x2 - 2*x1 + x0;
 
 if(abs(denominator) < epsilon) %Don't want to divide by too small of a number
 print('WARNING: denominator is too small')
 break; %Leave the loop
 end
 
 aitkenX = x2 - ( (x2 - x1)^2 )/(denominator);
 
 if(abs(aitkenX - x2) < tolerance) %If the result is within tolerance
 fprintf('The fixed point is %f', double(aitkenX)) %Display the result of the Aitken extrapolation
 haveWeFoundSolution = true;
 break; %Done, so leave the loop
 end
 
 
 x0 = aitkenX; %Update x0 to start again 
 
 end
 
 if(haveWeFoundSolution == false) %If we weren't able to find a solution to within the desired tolerance
 print('Warning: Not able to find solution to within the desired tolerance of ', tolerance);
 print('"The last computed extrapolate was ', aitkenX)
 end


ejecución

1
The fixed point is 1.414214>>




Saludos
JOSE JEREMÍAS CABALLERO
Asesoría online en Matlab
Servicios de programación matlab
jjcc94@hotmail.com
Estimado Usuario, el correo es para servicios de cursos, asesorías y programación. Toda ayuda gratuita es vía foro


http://matlabcaballero.blogspot.com
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

Error using mupadmex Error in MuPAD command: DOUBLE cannot convert the input expression into a doubl

Publicado por Pablo (3 intervenciones) el 15/11/2015 00:11:33
hola José, te cuento que copié y pegue lo mismo que tu me mandaste y al ejecutar me aparece esto, mi version de matlab puede influir? es la r2011b.

Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.

If the input expression contains a symbolic variable, use the VPA function instead.

Error in sym/double (line 936)
Xstr = mupadmex('symobj::double', S.s, 0);

Error in sym>privformatscalar (line 2707)
x = double(x);

Error in sym>privformat (line 2692)
s = privformatscalar(x);

Error in sym/subsasgn (line 1462)
[inds{k},refs{k}] = privformat(inds{k});

Error in Untitled3 (line 11)
f(x) = (1/2)*(x + 2/x) ; %The function that find the next element in the sequence

AQUI NUEVAMENTE EL CODIGO


%These choices depend on the problem being solved

clc

clear all

syms x

x0=1; %The initial value

f(x) = (1/2)*(x + 2/x) ; %The function that find the next element in the sequence

tolerance = 10^-10 ; %10 digit accuracy is desired

epsilon = 10^-16 ; %Don't want to divide by a number smaller than this


maxIterations = 20 ; %Don't allow the iterations to continue indefinitely

haveWeFoundSolution = false;%Were we able to find the solution to the desired tolerance? not yet.



for i = 1 : maxIterations

x1 = f(x0);

x2 = f(x1);



lambda = abs((x2 - x1)/(x1 - x0)); %OPTIONAL: computes an approximation of |f'(fixedPoint)|, which is denoted by lambda


denominator = x2 - 2*x1 + x0;


if(abs(denominator) < epsilon) %Don't want to divide by too small of a number

print('WARNING: denominator is too small')

break; %Leave the loop

end



aitkenX = x2 - ( (x2 - x1)^2 )/(denominator);



if(abs(aitkenX - x2) < tolerance) %If the result is within tolerance

fprintf('The fixed point is %f', double(aitkenX)) %Display the result of the Aitken extrapolation

haveWeFoundSolution = true;

break; %Done, so leave the loop

end





x0 = aitkenX; %Update x0 to start again



end



if(haveWeFoundSolution == false) %If we weren't able to find a solution to within the desired tolerance

print('Warning: Not able to find solution to within the desired tolerance of ', tolerance);

print('"The last computed extrapolate was ', aitkenX)

end
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

Error using mupadmex Error in MuPAD command: DOUBLE cannot convert the input expression into a doubl

Publicado por JOSE JEREMIAS CABALLERO (3432 intervenciones) el 15/11/2015 00:21:09
1
f= (1/2)*(x + 2/x) ; %The function that find the next element in the sequence
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

Error using mupadmex Error in MuPAD command: DOUBLE cannot convert the input expression into a doubl

Publicado por Pablo (3 intervenciones) el 15/11/2015 00:28:55
??? no entiendo a lo que te refieres.....
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

Error using mupadmex Error in MuPAD command: DOUBLE cannot convert the input expression into a doubl

Publicado por JOSE JEREMIAS CABALLERO jjcc94@hotmail.com (3432 intervenciones) el 15/11/2015 14:14:08
revisa el código que te mando, te estoy diciendo que modifiques ese línea ya que tu matlab no soporta la instrucción f(x). Tienes que leer los códigos y no es solo pegar.
saludos.
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