how to change matrix element from zero to 1

2 Ansichten (letzte 30 Tage)
amina shafanejad
amina shafanejad am 17 Mai 2015
Kommentiert: Stephen23 am 17 Mai 2015
hello i have one matrix 4 by 4 which only it has few zero element how can i say it check the element if less than one then change it to one ?

Antworten (1)

the cyclist
the cyclist am 17 Mai 2015
If A is your matrix,
A(A<1) = 1
  3 Kommentare
Walter Roberson
Walter Roberson am 17 Mai 2015
for K = 1
A = max(A,1);
end
Stephen23
Stephen23 am 17 Mai 2015
Why use a loop for this? It is faster and neater using the cyclist's vectorized code.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by