Find intersection of two guassian curves
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
jonas
2018-9-11
编辑:jonas
2018-9-11
If you have only one intersection, then you can just find the minimum difference
[~,idx] = min(abs(y1 - y2))
This will however always output a value even when there is no intersection. Also, the accuracy depends on the resolution of your x-vector, where higher resolution yields better accuracy (this is true for most methods). I always recommend InterX from FEX for finding intersections. It interpolates your data per default for high accuracy.
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Probability Distributions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!