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

조회 수: 5 (최근 30일)
Eymen Dogrusever
Eymen Dogrusever 2020년 5월 23일
댓글: Walter Roberson 2020년 5월 23일
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
Walter Roberson
Walter Roberson 2020년 5월 23일
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()

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by