Approximating an Intersection Point Between 2 Sets of Data

18 次查看(过去 30 天)
Hello - I've tried multiple ways to find an intersection point between two curves. The format of my data is two data sets, one set polynomial XY data (stress-strain) and one set linear XY data (0.2% offset curve). I've tried:
find(stress == offset); %This returns an empty answer
int = intersect(stress, offset); %This also returns an empty answer
I've then generated a polynomial from stress with 100,000 points and tried this again:
sp = polyfit(strain, stress, 7);
op = polyfit(offsetstrain, offset, 7);
x = linspace(0, offsetmax, 100000);
sp1 = polyval(sp, x);
op1 = polyval(op, x);
And still - I can't find an intersection point between the artificially generated curves or the raw data using "find" or intersect". Am I missing something?

回答(1 个)

Star Strider
Star Strider 2017-11-8
Use the fzero function, subtracting your two polynomials to get the point where the curves intersect:
Example
sp = [4 3 2 1];
op = [8 7 6 5];
f = @(x) polyval(sp, x) - polyval(op, x);
x_int = fzero(f, 1);
xv = linspace(-1.5, 0.5);
figure(1)
plot(xv, polyval(op, xv), xv, polyval(sp, xv))
hold on
plot(x_int, polyval(sp, x_int), 'pg', 'MarkerSize',10, 'MarkerFaceColor','g')
hold off
grid
  1 个评论
John D'Errico
John D'Errico 2017-11-8
The point of course, is you are thinking "intersection". So you look in MATLAB, and find the function intersect. Of course that must do what you want.
But intersect performs a set intersection. Think Venn diagrams, etc. You have a curve, defined by a set of points. Then you fit it using polynomials, but they are still not sets, just functions.
So you need to do as Star said, subtract the curves. Then look for a root of the difference.
Your problem arose here because of your mental description of the problem you want to solve.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Stress and Strain 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by