Replacing numbers in a row
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
John Doe
am 17 Apr. 2018
Kommentiert: John Doe
am 19 Apr. 2018
Dear all,
I have a question, I want to try to replace values in a row that are greater than zero. For example, I have the array A that is:
A = [ 0 0 3 5 6 4 0 0 0 3 0 0 3 2 0].
What I want is to replace all values greater than 0 by 1.I know I can use A(A>0)=1 but I don't want to replace the individual 3 by 1 instead I want it to be zero.
I want my result to be:
A = [ 0 0 1 1 1 1 0 0 0 0 0 0 1 1 0]....instead of A = [ 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0].
Is there any way I can do this and specify what individual number I don't want to replace by 1??
Thank You!!
6 Kommentare
Guillaume
am 18 Apr. 2018
So is it just the 3 that stand alone that are not to be replaced, or any number that stand alone?
Akzeptierte Antwort
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Pie Charts finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!