matlab matrix help

May 2010
2
0
hello,

using MATLAB

I currently have a matrix of the form:

[54 4 2 6 45;
.1 .2 .3 .4 .5]

I am trying to find a way to extract the column that contains the minimum row one value.

ie, for this case to extract 2 & 3

row one is minimum receptances
row two is the corresponding spring constants

so really all i actually need is to be able to extract the spring value from row 2 that corresponds to the minimum value in row 1


any help would me much appreciated
 

CaptainBlack

MHF Hall of Fame
Nov 2005
14,972
5,271
someplace
hello,

using MATLAB

I currently have a matrix of the form:

[54 4 2 6 45;
.1 .2 .3 .4 .5]

I am trying to find a way to extract the column that contains the minimum row one value.

ie, for this case to extract 2 & 3

row one is minimum receptances
row two is the corresponding spring constants

so really all i actually need is to be able to extract the spring value from row 2 that corresponds to the minimum value in row 1


any help would me much appreciated
Code:
A=[54 4 2 6 45;
    .1 .2 .3 .4 .5];
 
[r1,id]=sort(A(1,:));
 
B=A(:,id(1))
 
Mar 2007
206
33
If there is only one minimum value in the first row you could do it as follows also:

Code:
B = A(:,find(A(1,:)==min(A(1,:))))%provided there is only 1 minimum
Regards Elbarto
 
May 2010
2
0
Thanks heaps guys.

that first solution was exactly what we were after.

just handed the assignment in and am very happy with it so cheers for taking the time to help us out.