Unable to plot two functions to find the intersection points

Here is what I'm doing:
x=linspace(0, 1);
y1=abs(x).^-5 .* exp(x.^2) - atan(9976+1000);
y2=besselj(0,x);
plot(x, y1, x, y2);
When I plot this I get a graph with one line. How do I get both lines and then find there intersection points?

 採用された回答

Matt Fig
Matt Fig 2012 年 11 月 6 日
編集済み: Matt Fig 2012 年 11 月 6 日

1 投票

Try this way. You have to pay attention to the ylimits!
x=linspace(0, 5,1000);
y1=abs(x).^-5 .* exp(x.^2) - atan(9976+1000);
y2=besselj(0,x);
plot(x, y1, x, y2);
ylim([-10 10]) % Set the ylimit to a reasonable value!
Now you can look and guess at their intersection points. Say about x=1 and x=2. We can use FZERO to get a more exact location.
f = @(x) besselj(0,x)-(abs(x).^-5 .* exp(x.^2) - atan(9976+1000));
[fzero(f,1),fzero(f,2)]

2 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 6 日
Thanks Matt, I thought x=linspace(0, 1) generate just two values. Next time I will check before writting false things
Matt Fig
Matt Fig 2012 年 11 月 6 日
No worries, Azzi. My first thought was the same as yours, it is only because I remember checking this once that I knew...

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by