필터 지우기
필터 지우기

Why is cell array of doubles converting to NaN

조회 수: 2 (최근 30일)
Ron
Ron 2017년 6월 17일
댓글: dpb 2017년 6월 18일
I am reading in a .csv file with textscan:
y.Data = textscan(fileID, '%s%f%f%[^\n\r]', 'Delimiter', ',', ...
'EmptyValue' ,NaN,'HeaderLines', 1, ...
'ReturnOnError', false, 'TreatAsEmpty', '#VALUE!');
The first row is header text. The first column is a date time string. The remaining columns are numeric.
I then create variable names from the header text, and create a data structure with those names. I use the following to copy the imported data into the structure.
for chn = 1:y.nChan
y.Chan.(y.Name{chn}) = y.Data{chn};
end
Now if I look at y.Data{2} I see a cell array of doubles corresponding to the original data, but if I look at y.Chan.Signal1, for example, I see a cell array of doubles in which every value is NaN.
This has worked in the past, so not sure why it is not working now.
  댓글 수: 3
Ron
Ron 2017년 6월 17일
Okay, I'm embarrassed now. The most obvious question of course led to the most obvious problem. Each column heading has a very long tag which I was shortening to what I thought was the only relevant information; however, I see the data has two sources, the second of which was coming in as all NaN. In shortening the column names I was removing the info regarding source, so my code was reading in good data from the first source for each variable, and then overwriting with NaN from the bad source.
Thanks for taking time to look at the question and ask the question I should have asked myself to start with.
dpb
dpb 2017년 6월 18일
No problem...well all do such things now and again...

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

답변 (0개)

카테고리

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