필터 지우기
필터 지우기

A(B)=0 What is its meaning?

조회 수: 9 (최근 30일)
zhenyu zeng
zhenyu zeng 2019년 3월 6일
편집: Torsten 2019년 3월 6일
A=rand(5)
B=A>0.8
A(B)=0
Can you tell me what is A(B)=0 meaning?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2019년 3월 6일
B is a logical index matrix. You can see the value is 1 (true) or 0 (false) wherever the corresponding value in A is greater than 0.8.
A(B)=0 means for all those places where B's value is true, set the corresponding value in A to 0.
Use this example to see it better.
A=magic(5)
B=A>10
A(B)=0
  댓글 수: 3
Torsten
Torsten 2019년 3월 6일
편집: Torsten 2019년 3월 6일
It's the same as if you ask why MATLAB loops if you write
for i=1:n
...
end
It's just MATLAB syntax.
Look up "Logical indexing":
https://blogs.mathworks.com/loren/2013/02/20/logical-indexing-multiple-conditions/
Fangjun Jiang
Fangjun Jiang 2019년 3월 6일
It is a very efficient way for programming.

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

추가 답변 (1개)

Torsten
Torsten 2019년 3월 6일
편집: Torsten 2019년 3월 6일
All numbers in the matrix A that are bigger than 0.8 are set to 0.

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by