Replace an element of a vector by also redefining the vector
Mostrar comentarios más antiguos
Hi all,
I would like to replace some elements of a vector Vec that have indices idx with NaN, to create a new vector VecNaN. However, using the usual code below
Vec(idx) = NaN;
redefines the vector Vec with the NaN elements. Instead I want to find a new vector VecNaN such that it is the same as Vec, but with the NaN elements in the indices idx.
Thanks for your help in advance,
KMT.
Respuesta aceptada
Más respuestas (1)
Julie Kraus
el 3 de Ag. de 2017
If I am understanding you correctly you want 2 vectors out, your original and a new vector with NaN's in idx locations.
VecNaN=Vec;
VecNaN(idx)=NaN;
Categorías
Más información sobre NaNs en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!