saving regula-falsi iterations
Mostrar comentarios más antiguos
Hi everybody, I would like to save the iterations of X variable into a vector. I can only get the final resul, that is the solution equation, while my goal is that to obtain the whole series.
ex: x=[x1,x2,...,xn].
function [x,iter]= RegulaFalsi(f,a,b,ep,itermax)
x0=a;
x1=b;
iter=0; %number iterations
x=b;
while (abs(f(x)) > ep) && (iter<itermax)
x=x0-((f(x0)*(x1-x0))/(f(x1)-f(x0))); %intersection X axis
if (f(x)*f(x0)>0)
x0=x;
x1=b;
else (f(x)*f(b)>0)
x1=x;
x0=a;
end
if iter==itermax
disp('Maximum number of iterations reached')
end
iter=iter+1;
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!