increment values which are larger than three

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?

 채택된 답변

Mischa Kim
Mischa Kim 2014년 4월 2일

2 개 추천

Sososasa, use
B = A + (A>3)

추가 답변 (2개)

Carlos
Carlos 2014년 4월 2일
편집: Carlos 2014년 4월 2일

1 개 추천

Try
A=[ 2 1 3;
4 2 5;
1 1 6]
a=find(A>3);
A(a)=A(a)+1
Chandrasekhar
Chandrasekhar 2014년 4월 2일

1 개 추천

a = find(A>3);
A(a) = A(a)+1;

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2014년 4월 2일

댓글:

2014년 4월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by