Azzera filtri
Azzera filtri

can any one help me to plot this function and midpoint each time will be calculated ?

1 visualizzazione (ultimi 30 giorni)
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

Risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by