Any ideas to find intersection between tan(t) and y1, y2, and y3 line equations?

Hello! I want to find intersection between tan(t) and the following line equations but my code instead of giving me two intersection points, just giving me one at origin(0,0)
t=0:0.01:5;
y1=0.5*t; y2=t; y3=2*t;
i1=intersect(tan(t),y1)
i2=intersect(tan(t),y2)
i3=intersect(tan(t),y2)
HINT: There should be 2 intersection points for each one of i1, i2, and i3!

 採用された回答

Mohammed Sayan
Mohammed Sayan 2013 年 7 月 14 日
ieq1=@(t) tan(t)-0.5*t;
ieq2=@(t) tan(t)-t;
ieq3=@(t) tan(t)-2*t;
i1=fzero(ieq1,[pi 3*pi/2]);
i2=fzero(ieq2,[pi 3*pi/2]);
i31=fzero(ieq3,pi/4);
i32=fzero(ieq3,[pi 3*pi/2]);

その他の回答 (1 件)

Matt J
Matt J 2013 年 7 月 14 日
I assume you are looking for solutions on [-pi/2, pi/2].
The only one of the functions that has an intersection anywhere there but t=0 is y2. You can find the positive solution using fzero,
>> fun=@(t) tan(t)-2*t; [T,fval]=fzero(fun,3*pi/8)
T =
1.1656
fval =
4.4409e-16
The other solution is -T, due to the symmetry of the functions.

2 件のコメント

Mohammed Sayan
Mohammed Sayan 2013 年 7 月 14 日
Well, that was a good try! thanks. I want all intersections greater that ZERO.
Matt J
Matt J 2013 年 7 月 14 日
編集済み: Matt J 2013 年 7 月 14 日
You won't be able to have them all. There are infinitely many...

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSystems of Nonlinear Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by