필터 지우기
필터 지우기

Replace values in each column of a matrix which lie below a threshold

조회 수: 10 (최근 30일)
KostasK
KostasK 2020년 6월 3일
댓글: KostasK 2020년 6월 3일
Hi all,
Lets say I have the following matrix:
a =
0.9952 0.6999 0.2940
0.0034 0.2553 0.5776
0.3167 0.3135 0.4261
I would like to replace with zero the numbers in the first, second and thrid column that are less than 0.5, 0.3 and 0.8 respectivelly, so the result would be:
a_new =
0.9952 0.6999 0.0000
0.0000 0.0000 0.0000
0.0000 0.3135 0.0000
To do this, I try something like this a(a<[0.5 0.3 0.8],:)=0, however this doesn't work... Ideally I would like to avoid a for loop, so are there any other ways of accomplishing the above?
Thanks for your help in advance

채택된 답변

madhan ravi
madhan ravi 2020년 6월 3일
a(a < [0.5 0.3 0.8]) = 0
  댓글 수: 2
madhan ravi
madhan ravi 2020년 6월 3일
+1 to your question, you were so close impressive :p
KostasK
KostasK 2020년 6월 3일
OO, indeed that was close. Thanks for your help.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by