Compare values and change them

조회 수: 4 (최근 30일)
Akmyrat
Akmyrat 2014년 6월 13일
댓글: Azzi Abdelmalek 2014년 6월 13일
Lets say i have matrix A=[1 2 3;4 2 7;9 6 1] I want the values less than 5 to be replaced with zero, and bigger than 5 to be replaced with 1 in this case should be this answer A=[0 0 0;0 0 1;1 1 0] Hope someone will assist me...thanks.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 6월 13일
편집: Azzi Abdelmalek 2014년 6월 13일
A(A<5)=0
A(A>5)=1
You have to consider when the value is equal to 5
You can also have the result by
A=[1 2 3;4 2 7;9 6 1]
B=A>5
  댓글 수: 2
Akmyrat
Akmyrat 2014년 6월 13일
shukran Azzi Abdelmalek, how can i add all values less than 5? in this case will be 1+2+3+4+2+1=13
Azzi Abdelmalek
Azzi Abdelmalek 2014년 6월 13일

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by