How to find how many intersections in a graph?

조회 수: 2 (최근 30일)
Philip Chen
Philip Chen 2021년 10월 22일
댓글: KSSV 2021년 10월 25일
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!
%Constant
r=4
dx=0.01
%Ranges
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;
%Function
tanFunc=@(x) tan(x)
cotFunc=@(x1) -cot(x1)
circleFunc = @(x3) sqrt(16-x3.^2);
diff_fun = @(v) circleFunc(x2) - tanFunc(x3);
%Plotting
y1=tanFunc(x1)
hold on
y2=cotFunc(x2)
hold on
y3=circleFunc(x3)
%plot(x2, y2)
plot(x1, y1, x2, y2, x3, y3)
%Graph Addon
set(gca,'XLim',[0 r]);
set(gca,'YLim',[0 r]);

채택된 답변

KSSV
KSSV 2021년 10월 22일
편집: KSSV 2021년 10월 22일
  댓글 수: 2
Philip Chen
Philip Chen 2021년 10월 25일
Thanks. I found all of the intersections, but I want the program to display HOW MANY intersections that it found.
KSSV
KSSV 2021년 10월 25일
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.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by