Find intersection of two guassian curves
Show older comments
Hi all these are my two curves:
y1 = p(1)*pdf(n1,xgrid); hold on; plot (xgrid, y1,'b'); % hold off
y2 = p(2)*pdf(n2,xgrid); hold on; plot (xgrid, y2,'r'); % hold off
I need to find the exact x coordinates where this two lines meet.
I tried using:
index_intersection = find(y1 == y2);
but it gives me index_intersection =
1×0 empty double row vector
I also tried:
idx = find (y1 - y2 < eps, 1);
but still didn't get the right coordinates.
Please, is there another alternative? I read online that I could use fzero, but I haven't understood how to use the syntax. Thanks in advance.
3 Comments
Dimitris Kalogiros
on 11 Sep 2018
what exactly is p(1) and p(2) ?
jonas
on 11 Sep 2018
Check out InterX on FEX
Trisha Kibaya
on 11 Sep 2018
Accepted Answer
More Answers (1)
tol = 10^-3 ; % Change this if required
idx = abs(y1-y2)<=tol ;
3 Comments
Trisha Kibaya
on 11 Sep 2018
KSSV
on 11 Sep 2018
To compare two flottant numbers it is suggested to subtract check for inequality with tolerance, rather then using ==.
Trisha Kibaya
on 12 Sep 2018
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!