How do I replace Matrix elements
35 次查看(过去 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?
采纳的回答
另请参阅
类别
在 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!