Changing some elements of a matrix.

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.

 Respuesta aceptada

Joseph Cheng
Joseph Cheng el 9 de Abr. de 2014
Editada: Joseph Cheng el 9 de Abr. de 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.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 9 de Abr. de 2014

Editada:

el 9 de Abr. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by