Azzera filtri
Azzera filtri

how to change matrix element from zero to 1

2 visualizzazioni (ultimi 30 giorni)
amina shafanejad
amina shafanejad il 17 Mag 2015
Commentato: Stephen23 il 17 Mag 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 ?

Risposte (1)

the cyclist
the cyclist il 17 Mag 2015
If A is your matrix,
A(A<1) = 1
  3 Commenti
Stephen23
Stephen23 il 17 Mag 2015
Why use a loop for this? It is faster and neater using the cyclist's vectorized code.

Accedi per commentare.

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by