フィルターのクリア

How to choose a column where the min of the first row is

1 回表示 (過去 30 日間)
Reuben
Reuben 2014 年 2 月 9 日
コメント済み: Reuben 2014 年 2 月 9 日
Hello! I am new to Matlab and having a tough time doing the following. I have a set of distances computed for each respective time.
where all the list of distances is stored as 'd' and each RESPECTIVE time these distances occur at is 't'
I made a matrix A = [d;t]. Essentially...I want to find out the respective time value when d is minimum.
I tried to pick out the row as
>> A(2,min(d)). Obviously I see now how that doesn't work since its the column number and not for that value.
Is there anyway matlab can recognize which column number that min(d) exists...and then display the WHOLE column so i can also see the respective time value it exists at. Thanks!
FOR EXAMPLE:
a = [ 5 4 1 3 ] b = [ 1 2 3 4 ]
H = [a;b]
I want to display the column [1;3] since min(a) exists in this column. I need to keep each b value tied to each a however.

採用された回答

Mischa Kim
Mischa Kim 2014 年 2 月 9 日
編集済み: Mischa Kim 2014 年 2 月 9 日
Use
G = H(:,a==min(a))
or, the more general approach avoiding reference to a,
G = H(:,H(1,:)==min(H(1,:)))

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 9 日
a = [ 5 4 1 3 ]
b = [ 1 2 3 4 ]
[mina,idx]=min(a);
your_column=[mina;b(idx)]

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by