Filter löschen
Filter löschen

Replace selected elements in a vector if meeting some criteria

1 Ansicht (letzte 30 Tage)
Biswanath Mahanty
Biswanath Mahanty am 16 Okt. 2015
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?

Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by