How do I plot intersection point of a function and y axis in matlab
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
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()
Réponses (0)
Voir également
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!