Imported Numbers from excel are replaced by NaN!!(?)

조회 수: 9 (최근 30일)
Panos Ale
Panos Ale 2017년 5월 27일
댓글: Star Strider 2017년 5월 28일
Hello! I am trying trying to import(create a numeric matrix) some values from excel which have about 13 decimals but matlab relpaces them with NaN. What can I do?
  댓글 수: 2
John D'Errico
John D'Errico 2017년 5월 27일
Well, since we cannot replicate what you get, how can we help? Posting a spreadsheet where this happens, then showing how you tried to do the import would make it easier to help you. Attach a spreadsheet to a comment.
Panos Ale
Panos Ale 2017년 5월 27일
Here is the file! Thank toy for your help and understanding!

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

채택된 답변

Walter Roberson
Walter Roberson 2017년 5월 27일
importdata() cannot deal with using comma as the decimal separator.
Unfortunately to handle numbers that use comma as the decimal separator, you must replace the command with period before converting to numeric. For example if you have a cell array of strings, then
numeric_data = str2double( regexp(YourCellArrayOfStrings, ',', '.') )
  댓글 수: 1
Panos Ale
Panos Ale 2017년 5월 28일
편집: Panos Ale 2017년 5월 28일
Thank you very much!!

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

추가 답변 (1개)

Star Strider
Star Strider 2017년 5월 27일
The NaN values in the numeric output matrix usually occur if the Excel file cells are blank or have string data. Without seeing your Excel file, it is not possible to determine exactly what the problem may be otherwise.
  댓글 수: 3
Panos Ale
Panos Ale 2017년 5월 28일
편집: Panos Ale 2017년 5월 28일
I did it this way and it works fine for me too! Thanks!
Star Strider
Star Strider 2017년 5월 28일
My pleasure!

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

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by