Replacing values in a matrix

13 vues (au cours des 30 derniers jours)
Naoufel Farid
Naoufel Farid le 6 Fév 2021
Commenté : Naoufel Farid le 6 Fév 2021
Hello, I'm having trouble figuring out how to replace values in a matrix that fall between two values.
For example, lets say i have matrix, and i want to replace all values that fall between 20 and 50 with -3 instead, how would I go about doing that?

Réponse acceptée

Adam Danz
Adam Danz le 6 Fév 2021
Use basic Matlab indexing.
M(M>20 & M<50) = -3;
  1 commentaire
Naoufel Farid
Naoufel Farid le 6 Fév 2021
Thank you this worked great!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by