Borrar filtros
Borrar filtros

Why is cell array of doubles converting to NaN

2 visualizaciones (últimos 30 días)
Ron
Ron el 17 de Jun. de 2017
Comentada: dpb el 18 de Jun. de 2017
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 comentarios
Ron
Ron el 17 de Jun. de 2017
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 el 18 de Jun. de 2017
No problem...well all do such things now and again...

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Logical 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