Info

この質問は閉じられています。 編集または回答するには再度開いてください。

mat ops to locate values and place into new matrix

2 ビュー (過去 30 日間)
lightroman
lightroman 2017 年 12 月 1 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
column width should be length of longest row of 9s. I can do this by loops and placing the values into a preallocated zeroes matrix but its slow. The actual matrix is very very large.
if true
a = [1 9 3 5 2 7;
9 9 9 9 1 2;
6 5 0 3 9 9;
6 2 1 7 8 7;
4 9 9 9 9 9]
out = [9 0 0 0 0 0;
9 9 9 9 0 0;
9 9 0 0 0 0;
0 0 0 0 0 0;
9 9 9 9 9 0]
end

回答 (1 件)

Jos (10584)
Jos (10584) 2017 年 12 月 2 日
b = sort(a.*(a==9), 2, 'descend')

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by