How to find a corresponding matrix value

4 ビュー (過去 30 日間)
Lu Da Silva
Lu Da Silva 2020 年 9 月 17 日
回答済み: BOB MATHEW SYJI 2020 年 9 月 17 日
I have two matricies, Q and W, and I calculated the values of Q from the values of W. I then found the maximum values of each row in Q, but I also need to find the corresponding values of W from the other matrix and I'm not sure how to do that.

採用された回答

Turlough Hughes
Turlough Hughes 2020 年 9 月 17 日
You can get the corresponding values in W as follows
[mQ,idx] = max(Q,[],2,'linear')
W(idx)

その他の回答 (1 件)

BOB MATHEW SYJI
BOB MATHEW SYJI 2020 年 9 月 17 日
Hope this helps. yis the required vector
W=%your vector
Q=%vector obtained after operations on W
[v,u]=max(W')
for i=1:length(u)
y(i)=Q(i,u(i));
end

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by