フィルターのクリア

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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by