필터 지우기
필터 지우기

Replace selected elements in a vector if meeting some criteria

조회 수: 1 (최근 30일)
Biswanath Mahanty
Biswanath Mahanty 2015년 10월 16일
Assume A=rand(10,1) is a column vector. B is a vector of position assume B=[2 4 7]. I want to check if any of the 2,4,7th rows elements in A is <0.5. If yes, change those elements in A to zero. I want finally modified A.
Within a loop, I can assess each elements of B (i.e. 2,4,7 one after another) and check the condition and make changes in A - that's straightforward. Is there any smarter way?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by