How to find how many intersections in a graph?

5 views (last 30 days)
Philip Chen
Philip Chen on 22 Oct 2021
Commented: KSSV on 25 Oct 2021
I made this graph that focuses only on the first quadrant. I am supposed to display the number of intersections between the circle and the tangent and negative cotangent graphs, and I am stuck at this very point. Any help here is deeply appreciated!
x1 = 0:pi/100:5*pi/2-dx;
x2 = 0:pi/100:5*pi/2-0.01;
x3 = 0:pi/100:5*pi/2-0.01;
tanFunc=@(x) tan(x)
cotFunc=@(x1) -cot(x1)
circleFunc = @(x3) sqrt(16-x3.^2);
diff_fun = @(v) circleFunc(x2) - tanFunc(x3);
hold on
hold on
%plot(x2, y2)
plot(x1, y1, x2, y2, x3, y3)
%Graph Addon
set(gca,'XLim',[0 r]);
set(gca,'YLim',[0 r]);

Accepted Answer

KSSV on 22 Oct 2021
Edited: KSSV on 22 Oct 2021
KSSV on 25 Oct 2021
You caclulate the dimensions of the output from interX. I guess output of intersetion points is a row matrix.
N = size(P,2)
Number of columns should give you number of intrsection points.

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!