
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Finding an intersection between one data points curve and one linear curve (ax+b)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (1)
Sam Cook
am 13 Jun. 2018
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 Kommentar
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!