Matlab - Problema con codigo de newton-Raphson

 
Vista:

Problema con codigo de newton-Raphson

Publicado por Cristian (1 intervención) el 16/05/2016 08:25:10
Buenas tengo un problema espero me puedan ayudar.

tengo un código de newton-raphson que me funciona muy bien, cuando lo ejecuto por ventana de comandos.

El problema aparece cuando le monte una interfaz gráfica con GUI en matlab, y me esta generando un error que no se porque sale, ingreso los valores normalmente y cuando le doy en calcular me sale un error.
El mensaje de error es este:

Error in NewtonRaphson>calcular_Callback (line 187)
fx(i+1)=fx(i)-f1/d;



el codigo que tengo es este:

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
syms x;
f=get(handles.txtFx,'string');
x0=str2double(get(handles.txtX0,'string'));
tol=str2double(get(handles.txtError,'string'));
pos=1;
 
i=1;
fx(i)=x0;
syms x;
f1=subs(f,x,fx(i));
z=diff(f);
d=subs(z,x,fx(i));
ea(1)=100;
while abs(ea(i))>=tol;
fx(i+1)=fx(i)-f1/d;
f1=subs(f,x,fx(i+1));
d=subs(z,x,fx(i+1));
ea(i+1)=abs((fx(i+1)-fx(i))/fx(i+1)*100);
i=i+1;
end
for j=1:i;
tabla(pos,1)= j-1;
tabla(pos,2)= fx(j);
tabla(pos,3)= ea(j);
pos=pos+1;
end
set(handles.uitable1,'Data',tabla);

Muchas gracias.
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
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

Problema con codigo de newton-Raphson

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 12/10/2018 23:25:13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
f=str2sym(get(handles.txtFx,'string'));
x0=str2double(get(handles.txtX0,'string'));
tol=str2double(get(handles.txtError,'string'));
pos=1;
i=1;
fx(i)=x0;
f1=subs(f,x,fx(i));
z=diff(f);
d=subs(z,x,fx(i));
ea(1)=100;
while abs(ea(i))>=tol
fx(i+1)=fx(i)-f1/d;
f1=subs(f,x,fx(i+1));
d=subs(z,x,fx(i+1));
ea(i+1)=abs((fx(i+1)-fx(i))/fx(i+1)*100);
i=i+1;
end
for j=1:i
tabla(pos,1)= j-1;
tabla(pos,2)= fx(j);
tabla(pos,3)= ea(j);
pos=pos+1;
end
set(handles.uitable1,'Data',tabla);


Saludos
JOSE JEREMIAS CABALLERO
Asesor de Proyectos con Matlab
Servicios de programación matlab


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