How do I replace Matrix elements
14 ビュー (過去 30 日間)
古いコメントを表示
Given a matrix A replace elements not equal 0 and not equal 1 by 5. Use disp() function to print out the resulting array.
So far I've got
A(A~=0) = 5;
disp(A);
but do not know how to make it 0 AND 1.
2 件のコメント
KSSV
2020 年 10 月 27 日
When you use ~=0 and replace those with 5, the elements whch have 1 also will be eplaced by 5 right?
採用された回答
Sudhakar Shinde
2020 年 10 月 27 日
編集済み: Sudhakar Shinde
2020 年 10 月 27 日
Try this:
A((A>1)|(A<0))=5
5 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!