newton rapshon
Publicado por Carlos Rojas (10 intervenciones) el 05/07/2012 17:10:26
hola a todos estoy tratando de simular newton rapshon con mi guide pero me sale error este para ser mas excactos.
?? Error using ==> mrdivide
Matrix dimensions must agree.
??? Error while evaluating uicontrol Callback
y este es mi codigo para mostraren mis textbox
?? Error using ==> mrdivide
Matrix dimensions must agree.
1
2
3
4
5
6
7
8
9
10
Error in ==> Newton>calcular_Callback at 243
fx(i+1)=fx(i)-(f1/d);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> Newton at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)Newton('calcular_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
y este es mi codigo para mostraren mis textbox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
x0 = str2double(get(handles.txtx0, 'string'));
tol= str2double(get(handles.txttol, 'string'));
f = str2double(get(handles.txtf, 'string'));
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
%fprintf('i fx(i) Error aprox (i) \n');
for j=1:i;
%fprintf('%2d \t %11.7f \t %7.3f \n',j-1,fx(j),ea(j));
set(handles.txtfxi, 'string', num2str(j-1) );
set(handles.txtfxi, 'string', num2str(fx(j)) );
set(handles.txtfxi, 'string', num2str(ea(j)) );
end
Valora esta pregunta


0