フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Finding an intersection between one data points curve and one linear curve (ax+b)

1 回表示 (過去 30 日間)
Lucille Bornowsky
Lucille Bornowsky 2018 年 6 月 5 日
閉鎖済み: Lucille Bornowsky 2018 年 6 月 14 日
Hi, I work on these two curves. One is a linear data curve of expression y=ax+b, with a and b known, and the other is a curve of experimental points x_exp and y_exp. I want to find the smaller x for which this curve intersect, or at least are close enough so that we can say that they intersect. x_exp is a vector ordinated from the smaller x to the bigger x.
To do so, for each x_exp rank i from the smallest to the biggest, I calculate "delta", the gap between the coordinate y_calc (given by the linear expression ycalc=ax_exp(i)+b) and y_exp. I keep in a vector intersections all the ranks i of the gaps x(i) for which the gap delta between y_calc and y_exp is smaller than 50. However, the code doesn't work. The gap values calculated are odds, and the intersections are not the values i should find. Do anyone know where my logic/code is flawed ? Do anyone has an idea regarding how to find the intersection of these curves ? Thank you very much. Here is my code:
u=1; %used to build the intersections vector
nb_exp_value=size(x_exp);
for i=1:nb_exp_value
y_calc= a*x_exp(i)+b;
delta= abs(y_exp( i )) - abs(y_calc);
if delta < 50
intersections(u)=i
u=u+1;
end
end

回答 (1 件)

Sam Cook
Sam Cook 2018 年 6 月 13 日
I think that the polyxpoly function is what you're looking for. It's part of the Mapping Toolbox.
X1 = -5:0.1:2;
Y1 = 3*X1 + -2; % Your linear data
X2 = -5:2;
Y2 = atan(X2) * 10; % Your experimental data
[Xi, Yi] = polyxpoly(X1, Y1, X2, Y2); % Intersection points
hold on
plot(X1, Y1);
plot(X2, Y2);
scatter(Xi, Yi, 'r*');
  1 件のコメント
Image Analyst
Image Analyst 2018 年 6 月 13 日
Lucille, attach your data in a .mat file if you want any more help.

この質問は閉じられています。

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by