How can I collect the values that I want ?
Show older comments
I have this code;
for k1 = 1:length(X)
for k2 = 1:length(X_inv)
DE(k1,k2) = hypot(X(k1)-X_inv(k2), Y(k1)-Y_inv(k2));
% Euclidean Distance
end
end
It works for finding distances from one point to anothers between [X Y] (X,Y give the position of points) matrix and [X_inv Y_inv] matrix. As you see in the image, X,Y creates the 2nd curve and it starts from below until meet the 1st curve above. At the beginning of 2nd curve, the position of X is greater than X_inv (X > X_inv).
Due to shape of this curve, there occurs X < X_inv. Afterward, (again)value of X starts to get bigger. I want DE(k1,k2) collects the values until the limit condition is
X(k1) <= X_inv(k2) && Y(k1)<=Y_inv(k2).
and I do not want the program stops at the beginning, want to stop when they are close each other.
Afterward, I find the minimum value of DE.
I want to collect the points while X(k1) <= X_inv(k2) && Y(k1)<=Y_inv(k2).
But There is a problem I can not solve. THE PROBLEM is;
When I apply
X(k1) <= X_inv(k2) && Y(k1)<=Y_inv(k2),
my program stops before I want. Because at first, "X > X_inv" Curves:

As you see in the image, X,Y creates the 2nd curve and it starts from below until meet the 1st curve above. At the beginning of 2nd curve, the position of X is greater than X_inv (X > X_inv).
Due to shape of this curve, I want DE(k1,k2) collects the values until the limit is as;
X(k1) <= X_inv(k2) && Y(k1)<=Y_inv(k2).
2nd curve should stop when it reaches the limitation.
5 Comments
Star Strider
on 30 Nov 2015
I do not have your data, but if I understand your Question correctly, one option would be to use the find function to return the index values of the minimum y-value for ‘1st Curve’ and use it again to find the maximum y-value of ‘2nd Curve’. Then use those indices to get the corresponding x-values.
Ender Rencuzogullari
on 30 Nov 2015
Edited: Ender Rencuzogullari
on 30 Nov 2015
Star Strider
on 30 Nov 2015
I remember it!
One possibility is for you to use min, max (both with two outputs) or find to get the minimum y-value of 1st curve and the maximum of 2nd curve and their indices, and then use those to define the (x,y) values of the other curve.
It would seem that the nearest values of the two would correspond to the values you want to connect, so I would use those k1 and k2 values to define them.
Ender Rencuzogullari
on 30 Nov 2015
Ender Rencuzogullari
on 30 Nov 2015
Edited: Ender Rencuzogullari
on 30 Nov 2015
Accepted Answer
More Answers (0)
Categories
Find more on Fit Postprocessing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!