Find out the intersection of two curves despite NaN-Values
1 view (last 30 days)
Show older comments
Benedikt Friedrich Nowak
on 8 Nov 2022
Commented: Benedikt Friedrich Nowak
on 9 Nov 2022
Hello there,
im struggeling with a the intersection of two curves. One curve is defined as a function :
x= (0 : 50)
y=(m*x)+yaxis (m and yaxis are constants).
The other curves is defined as a dataset of two vectors. Lets say:
V1=[1 2 3 4 5] and V2=[50 80 NaN 90 100].
Right now im using polyxpoly, but it struggels with the NaN-Value:
[xi,yi] = polyxpoly(V1,V2,x,y)
xi and yi would be the intersection.
Does anyone have a better alternative ?
Thank you for your help, Ben !
0 Comments
Accepted Answer
Jan
on 8 Nov 2022
Edited: Jan
on 8 Nov 2022
x = 0:50;
m = 0.234;
yaxis = 60;
y = (m*x)+yaxis;
V1 = [1 2 3 4 5];
V2 = [50 80 NaN 90 100];
V1(isnan(V2)) = nan; % Avoid error message from polyxpoly
[xi,yi] = polyxpoly(V1,V2,x,y)
plot(x, y);
hold('on');
plot(V1, V2);
plot(xi, yi, 'ok')
I'm not sure what "it struggels with the NaN-Value" means. Without setting the x-value to NaN at locations, where the y-value is NaN, polyxpoly throghs an error. But with a cleaning the code runs fine. So what exactly is the problem?
More Answers (0)
See Also
Categories
Find more on Data Exploration 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!