How to replace elements using logical operations?

조회 수: 1 (최근 30일)
LeBron
LeBron 2014년 5월 19일
답변: Friedrich 2014년 5월 19일
Let A = [2 13 1; 2 5 16; 11 9 8]
What I want to do is for element that are less than 6, replace the element with 0.
How do I do this using for/if operation ?
Thanks in advance.

채택된 답변

Friedrich
Friedrich 2014년 5월 19일
Hi,
try
>> A(reshape(A < 6,[],1)) = 0

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by