hi
i have taken an argument from matrix B (the maximun value from column)
now i want to the take the row that the argument is shown in and make from it a vector.
how can i do it ?
thanks
tal shmuel

 採用された回答

dpb
dpb 2020 年 2 月 11 日
編集済み: dpb 2020 年 2 月 13 日

0 投票

m=randi(200,4) % sample data
m =
125 95 46 63
118 47 35 185
42 169 46 87
61 39 88 37
The engine:
[~,v]=max(m);
yields
>> v =
1 3 4 2
>>
ADDENDUM:
Ok, latest guess as I thought prior was unlikely...let me try one more time to see if follow...
[~,ix]=max(m(:)); % index of overall maximum in matrix m
[r,c]=ind2sub(size(m),ix); % convert index to row,column location in m
v=m(r,:) % row of m corresponding to that location
result for above sample m is:
>> v =
118 47 35 185
>>
That what you looking for?

4 件のコメント

dpb
dpb 2020 年 2 月 11 日
OP Answer moved to Comment...dpb
thanks !
in your example i can see the max value in the matrix is 185 at m[2,4]
after the find of the max argument i want to make a vector from its row
thats my problem
dpb
dpb 2020 年 2 月 11 日
Then I don't understand the question.
Variable v is the row of the maxima of each colum.
The max of the first column is 125 in row one which is the value of v(1) while v(4) is 4 to match it.
tal shmuel
tal shmuel 2020 年 2 月 12 日
just to clearly me question,
i have a big matrix. the results of the matrix is the last column (the maximum value that i search)
when i find the maximun value i want to export all the row that its inclulded for and make from the row a vector that its size like the raw size matrix.
dpb
dpb 2020 年 2 月 12 日
OK, see if my latest update above hits the target...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2019a

タグ

質問済み:

2020 年 2 月 11 日

編集済み:

dpb
2020 年 2 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by