For loop only once
显示 更早的评论
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])
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!