How do I plot intersection point of a function and y axis in matlab

5 vues (au cours des 30 derniers jours)
Eymen Dogrusever
Eymen Dogrusever le 23 Mai 2020
Commenté : Walter Roberson le 23 Mai 2020
Sketch the graph of the function y = f(x) and the y-axis onto the same figure. What is the meaning of the point of intersection? Apply the Secant method to solve f(x) = 0 accurate to within 10^(-3) for the equation
A) f(x) = e^x + 2^(-x) + 2 cos(x) ) 6 for 1 x 2.
clc;
clear;
x=[1 2];
y=exp(x)+power(2,(-x))+2*cos(x)-6;
plot(x,y)
%Secant method;
f=@(x) exp(x)+power(2,(-x))+2*cos(x)-6;
x0=1;
x1=2;
epsilon=0.001;
err=abs(x1-x0);
if f(x0)*f(x1)>0
disp('enter valid interval!!!')
else
while err>epsilon
x2=(x0*f(x1)-x1*f(x0))/(f(x1)-f(x0));
x0=x1;
x1=x2;
err=abs(x1-x0);
root=x2;
end
fprintf('\n The root is %4.3f ',root)
end
I can solve the secant method part but I can't plot the intersection point of the function and y-axis.
I would appreciate if you can tell me or show me how can I plot?
  1 commentaire
Walter Roberson
Walter Roberson le 23 Mai 2020
The interesection point of the function and the y axis is just the point at which the function equals 0. You can plot a marker there or a line such as with xline()

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by