How to find corresponding x values for array of y values

7 次查看(过去 30 天)
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?

采纳的回答

Cris LaPierre
Cris LaPierre 2021-2-18
编辑:Cris LaPierre 2021-2-18
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))
MN = 1×3
0.2223 0.2202 0.8156
I = 1×3
2 1 2
x(I)
ans = 3×1
10 3 10
  1 个评论
Meagan Rhyne
Meagan Rhyne 2021-2-18
Thank you! That's exactly what I needed. I'm relatively new to MatLab and don't quite know what commands exist for these things. I appreciate your help!

请先登录,再进行评论。

更多回答(1 个)

David Hill
David Hill 2021-2-18
Assuming the first column is x and the remaining columns y of matrix M
[min,idx]=min(M(:,2:end));
x=M(idx,1);

Community Treasure Hunt

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

Start Hunting!

Translated by