Replace some values of a vector with another vector which has a different size
3 visualizzazioni (ultimi 30 giorni)
I've got the vector: source = [ 0 0 1 0 1]
and the vector a = [2 3],
which has a different size to source.
I'd like to replace in the source vector the elements that are equal to 1, with those of vector a.
The final vector b should be: b = [0 0 2 0 3]
Any thoughts on this?
Più risposte (2)
pfb il 29 Apr 2015
of course this works only if the number of nonzero elements in source are the same as the elements in a.