필터 지우기
필터 지우기

How to remove five lines before every NaN in the vector?

조회 수: 1 (최근 30일)
Daria Ivanchenko
Daria Ivanchenko 2020년 4월 27일
댓글: Walter Roberson 2020년 4월 27일
Hi everybody!
I am working with eye movements and currently analyzing some data from my experiments. I have a vector of data in Matlab which is indicating the position of the eye. After I imported the ASCII-file to the Matlab, I started to have some strange numbers before every NaN in the vector (I am attaching the file). How can I remove about 5 arrays before and after every NaN in the vector? These arrays I want to replace with NaNs again. I know that it should be really easy to do but my Matlab skills are not enough.
I will very grateful if somebody can help.
Thank you!
Best,
Daria

답변 (1개)

Walter Roberson
Walter Roberson 2020년 4월 27일
NL = find(isnan(Data));
zap_at = unique(NL+(-5:5));
Data(zap_at) = nan;
  댓글 수: 2
Daria Ivanchenko
Daria Ivanchenko 2020년 4월 27일
Thank you, Walter! Should I put the name of my vector instead of Data? And what is NL and zap_at?
Sorry, I am just too bad in Matlab :(
Walter Roberson
Walter Roberson 2020년 4월 27일
yes Data is your vector.
NL is nan locations, the places that the nans are.
zap_at is the places to overwrite with nan.
The code assumes that some of the nan might be within 5 of each other and filters out the duplicates. You could probably get away without the unique() call.
The code as written relies on R2016b or later

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by