Find out the intersection of two curves despite NaN-Values
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Benedikt Friedrich Nowak
le 8 Nov 2022
Commenté : Benedikt Friedrich Nowak
le 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 commentaires
Réponse acceptée
Jan
le 8 Nov 2022
Modifié(e) : Jan
le 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?
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Exploration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!