Whenever I import data from excel, one of the column that contains values such as 2.1ELKFJQL​HxxxMxxxxx​Sx4xxxIxSx​JJxxxxx, ends up with NaN in Matlab table.

조회 수: 38 (최근 30일)
I am working on a table that contains columns such as timestamp, machine status, valueAsString, etc. The problem here is: whenever I upload the excel file with this columns to Matlab, the 'column D' that contains values such as 2.1ELKFJQLHxxxMxxxxxSx4xxxIxSxJJxxxxx ends up with a NaN in Matlab table.
For convenience, I have attached the sample data, and the 'column D', is the one I want to be displayed in the right way in Matlab.
  댓글 수: 1
dpb
dpb 2018년 5월 16일
편집: dpb 2018년 5월 16일
  • Attach a small section of the data file, not an image; nobody can do anything with an image.
  • How are you trying to read the spreadsheet; we can't see your terminal from here...
  • For customized data import and additional control over the import process, define and use the import options (see detectImportOptions help)

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

채택된 답변

Jan
Jan 2018년 5월 16일
편집: Jan 2018년 5월 16일
You forgot to post your code. I guess it is:
[num, txt, raw] = xlsread(FileName);
Now you observe, that the file of num is set to NaN, if the Excel sheet contains the data
2.1ELKFJQLHxxxMxxxxxSx4xxxIxSxJJxxxxx
This is the expected and wanted behavior, because this is not a number. The field is imported in the 3rd output raw in its native format, as explained in the documentation.
Or may you use readtable? This is the problem when not posting the code: Writing an answer requires guessing. If so, specify the 'Format' accordingly, such that this field is not interpreted as a number.
  댓글 수: 1
Abdul Rehan Khan Mohammed
Abdul Rehan Khan Mohammed 2018년 5월 16일
Thanks for the quick reply. Since, I am working on huge data sets. I am using 'datastore' and 'readall' functions.
% ds=datastore('C:\Users\1 Months Data(Build string).xlsx'); % ds=readall(ds);

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by