lnk
lnk

Reputation: 603

replace elements of vector by condition

I have got a vector a and a vecor b. And a have bound vectors lb and ub. I want to replace: a[i] = b[i] if lb[i]<b[i]<ub[i]. How should I do it without loops?

Upvotes: 1

Views: 58

Answers (1)

user664303
user664303

Reputation: 2063

M = lb < b & b < ub;
a(M) = b(M);

Upvotes: 5

Related Questions