简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM