For loop only once
Mostrar comentarios más antiguos
Hi i want get root of equation.
but my script shows many same roots. i want show like function roots.
how can i do more?
clc
clear
pre_x1=0;
x2=[];
eps = 1e-9;
for n = -100:1:100
options = optimset('Display', 'off');
x1 = fzero('x^3 -6*x^2 + 11*x -6',n,options);
if (isnan(x1) == 0 && pre_x1 ~= x1)
% fprintf('guess = %5d, sol=%f10.n\n',n,x1);
if x1 == x1
pre_x1 = x1;
x2(end+1) = x1;
end
end
end
x2
roots([1 -6 11 -6])
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB 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!