Azzera filtri
Azzera filtri

Replace selected elements in a vector if meeting some criteria

1 visualizzazione (ultimi 30 giorni)
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?

Risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by