How do you use the NaN function?

1 visualización (últimos 30 días)
Nicholas Deosaran
Nicholas Deosaran el 14 de Sept. de 2020
Comentada: Abdolkarim Mohammadi el 14 de Sept. de 2020
How would write a code that for a vector that is 500 data points long, but the first 123 data points are NaN?

Respuestas (1)

Abdolkarim Mohammadi
Abdolkarim Mohammadi el 14 de Sept. de 2020
Editada: Abdolkarim Mohammadi el 14 de Sept. de 2020
You first create the NaN vector using nan(), then fill in the elements.
V = nan (500,1);
V (124:end) = Data;
  4 comentarios
Nicholas Deosaran
Nicholas Deosaran el 14 de Sept. de 2020
I am still not understanding
the code will be like
v = (500,1)
data = (1:123)=nan
is that right or no?
Abdolkarim Mohammadi
Abdolkarim Mohammadi el 14 de Sept. de 2020
No. If you have your vector of values for 125 to 500 and you want to transfer them to the new vector, then you should use:
V = nan (500,1);
V (124:end) = Data;
Otherwise, if you have a 500 element vector and you want to eliminate the first 125 elements, then you can do it in one command (not the one you mentinoed):
Data (1:123) = NaN;

Iniciar sesión para comentar.

Categorías

Más información sobre NaNs en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by