replacing a vector elemnts from another vector of the same size

7 ビュー (過去 30 日間)
A Aln
A Aln 2019 年 3 月 26 日
コメント済み: A Aln 2019 年 3 月 26 日
Hello
Im trying to replace some values in one vector to values from another vector in the same location
let says this is my vector:
5
3
8
2
3
and i have this vector
99
0
23
0
0
I want to replace zeros in the second vector to be like this
99
3
23
2
3
Are there any effiecient way to do that
Many thanks

採用された回答

Walter Roberson
Walter Roberson 2019 年 3 月 26 日
mask = second_vector == 0;
second_vector(mask) = first_vector(mask);

その他の回答 (0 件)

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by