How do I replace Matrix elements
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Liam Bouchereau
am 27 Okt. 2020
Bearbeitet: Stephen23
am 27 Okt. 2020
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 Kommentare
KSSV
am 27 Okt. 2020
When you use ~=0 and replace those with 5, the elements whch have 1 also will be eplaced by 5 right?
Akzeptierte Antwort
Sudhakar Shinde
am 27 Okt. 2020
Bearbeitet: Sudhakar Shinde
am 27 Okt. 2020
Try this:
A((A>1)|(A<0))=5
5 Kommentare
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!