Borrar filtros
Borrar filtros

increment values which are larger than three

1 visualización (últimos 30 días)
Sososasa
Sososasa el 2 de Abr. de 2014
Comentada: Sososasa el 2 de Abr. de 2014
Hi,
If I have this matrix:
A=[ 2 1 3;
4 2 5;
1 1 6]
and I want to increment any value larger than three, so the resulting matrix look like this:
A=[2 1 3;
5 2 6;
1 1 7]
So here I increased 4,5,6 to be 5,6,7
Is there a nice way to use that without loop?

Respuesta aceptada

Mischa Kim
Mischa Kim el 2 de Abr. de 2014
Sososasa, use
B = A + (A>3)

Más respuestas (2)

Carlos
Carlos el 2 de Abr. de 2014
Editada: Carlos el 2 de Abr. de 2014
Try
A=[ 2 1 3;
4 2 5;
1 1 6]
a=find(A>3);
A(a)=A(a)+1

Chandrasekhar
Chandrasekhar el 2 de Abr. de 2014
a = find(A>3);
A(a) = A(a)+1;

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by