I have a matrix, which looks like 150 110 95 110 200 and so on. Now, i want to replace all elements up 95 (or less than 100) to 100, so that my new matrix should look like 100 100 100 110 200 Can anyone suggest me a good way to do this? Thanks.

 Réponse acceptée

Joseph Cheng
Joseph Cheng le 9 Avr 2014
Modifié(e) : Joseph Cheng le 9 Avr 2014
I do not understand what you want to replace but if you know the inequality statement (A<B) you can do something like this
MATRIX(MATRIX<100) = 100; which will set all elements within your matrix which is less than 100 to 100.
or if there are two inequalities to satisfy.
MATRIX(MATRIX<100 & MATRIX>95) = 100; Set all elements in MATRIX which are between 95 and 100 to 100.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by