InterX not accurate for one intersection point

11 vues (au cours des 30 derniers jours)
Pa342
Pa342 le 5 Sep 2018
Commenté : jonas le 5 Sep 2018
I have tried to find the intersection between two lines, but it appears InterX (link below) does not return a particularly accurate value for the first intersection point. Is this the way the function works, or is it a problem with the way I am using it? Is there anyway to improve the accuracy? The code to plot the data is below and the data file is attached. The x co-ordinates are the same for both curves.
InterX: https://uk.mathworks.com/matlabcentral/fileexchange/22441-curve-intersections
clear all
close all
clc
load rawdata.mat
points = InterX([vor_x_pdf;y_poi],[vor_x_pdf;vor_y_pdf]);
loglog(vor_x_pdf,vor_y_pdf);
hold on
loglog(vor_x_pdf,y_poi);
ylim([0.001 1]);
EDIT: I've removed the file since a solution has been given.

Réponses (1)

jonas
jonas le 5 Sep 2018
Modifié(e) : jonas le 5 Sep 2018
It's because you're comparing the points one loglog scale. I suspect InterX uses linear interpolation to find the point of intersection. Try drawing a straight line on the linear scale between two points and then look at the same line on a loglog scale. It will be curved (with some exceptions)!
  2 commentaires
Pa342
Pa342 le 5 Sep 2018
Modifié(e) : Pa342 le 5 Sep 2018
Thanks. I have managed to find the intersection point by linearly interpolating, using "interp1", between the points on the curve. Essentially this adds more points to the curves which helps InterX find the approximate location of the intersection to a higher accuracy.
jonas
jonas le 5 Sep 2018
Yep, that would solve the issue!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by