can any one help me to plot this function and midpoint each time will be calculated ?
1 回表示 (過去 30 日間)
古いコメントを表示
can any one help me to plot this function and midpoint each time will be calculated ?
% % function [x,n2] = cal
fun='x^2-7*x+10';
a=1;
b=4;
TOL=0.01;
NO=100;
h = 10;
fx=2*TOL; n2=0;
j = 0;
while(abs(fx)>TOL)&&(n2<=NO)
x=a;
fa=eval(fun);
x=(a+b)/2;
fx=eval(fun);
n2=n2+1;
if(sign(fx)==sign(fa))
a=x;
else b=x;
end j=j+1; cArray(j)=x;
% plot(fx,'marker','*');
% hold on % plot(cArray)
% plot(b,fx,'marker','o')
% plot(fx,'marker','*');
% hold on; % plot(x);
% plot(b);
end
axis([-0.5 6 -0.5 6])
xL = xlim;
yL = ylim;
xlabel('x-axis')
ylabel('y-axis')
line([0 0], yL,'color','black');
%x-axis line(xL, [0 0],'color','black');
%y-axis end end
end
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!