MATLAB Answers

Replacing the zero entry of a vector with the corresponding entry of another vector of the same dimension.

1 view (last 30 days)
Hassan on 18 Feb 2018
Edited: Hassan on 20 Feb 2018
Hello everyone,
Please I need some help about this:
Suppose I have 2 vectors A=[0;2;0] and B=[3;5;7]. How can I write a command in MATLAB that simply replace the zero entries of vector A with the corresponding non-zero entries of vector B?
In general, if I have 2 vectors A and B of the same dimension, assuming vector A have some zero entries, but the vector B have no zero entries. How can I replace the all the zero entries of vector A with that of the corresponding entries of vector B?
Thanks for any help.

Accepted Answer

Birdman on 18 Feb 2018

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!