How to find corresponding x values for array of y values
6 views (last 30 days)
Show older comments
Meagan Rhyne
on 18 Feb 2021
Commented: Meagan Rhyne
on 18 Feb 2021
Hello,
I have imported data from an image processing software where I have a series of stacked x-y coordinates (from a stacked image). My raw data consists of one column of x-values and over 400 columns of y-values. In MatLab, I currently am able to produce a1x465 array with each minimum value of y from each y column. How can I find the cooresponding x-value for each min value of y?
0 Comments
Accepted Answer
Cris LaPierre
on 18 Feb 2021
Edited: Cris LaPierre
on 18 Feb 2021
Use the following syntax
When you are taking the min of an mxn array, I is a vector containnig the row numbers of the minimum values. Use that to index into your column of X values.
x = [3;10];
[MN,I] = min(rand(2,3))
x(I)
More Answers (1)
David Hill
on 18 Feb 2021
Assuming the first column is x and the remaining columns y of matrix M
[min,idx]=min(M(:,2:end));
x=M(idx,1);
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!