Eliminate zeros from array
3 ビュー (過去 30 日間)
古いコメントを表示
I have to arrays: A=[0 1 0 4; 2 0 3 4] and B= [1 2 3 4; 5 6 7 8]
I want to eleiminate zeros from matrix A and the corresponding values from matrix B. The solution is:
A=[1 4 2 3 4] and B=[2 4 5 7 8]
0 件のコメント
回答 (1 件)
James Tursa
2018 年 4 月 30 日
AT = reshape(A',1,[]);
BT = reshape(B',1,[]);
B = BT(AT~=0);
A = AT(AT~=0);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!