How do you use the NaN function?

조회 수: 1 (최근 30일)
Nicholas Deosaran
Nicholas Deosaran 2020년 9월 14일
댓글: Abdolkarim Mohammadi 2020년 9월 14일
How would write a code that for a vector that is 500 data points long, but the first 123 data points are NaN?

답변 (1개)

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020년 9월 14일
편집: Abdolkarim Mohammadi 2020년 9월 14일
You first create the NaN vector using nan(), then fill in the elements.
V = nan (500,1);
V (124:end) = Data;
  댓글 수: 4
Nicholas Deosaran
Nicholas Deosaran 2020년 9월 14일
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 2020년 9월 14일
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;

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by