Imported data becomes NaN
Ältere Kommentare anzeigen
I'm trying to import data from an excel document with many rows and columns.
When I import it in any way Matlab gives Nan.
Ex. 1. I import from excel as Table (also tried column vectors, column vectors and numeric matrix), If I open it in the workspace I see numbers. When loading in matlab command window it becomes NaN all of it.
Ex 2. I save the excel into txt files and other various file types and try to use "loadtable", "readcell", "load" but it becomes "NaN" or "1x1 missing".
Does anyone have an idea of what I'm doing wrong?
Update, I can now see the reason for my troubles are that the imported file gives many NaN and I didn't realise I had so many NaN in the end. All columns are not the same length. Now I just need to remove remove all NaN. I assume I need to take each column and remove nan for that column.
4 Kommentare
dpb
am 17 Okt. 2022
Not without seeing either of the actual code used nor the file, no.
But, the problem will more than likely lie in just what the content of the Excel file actually is.
One thing to try until you can post back the needed information outlined above is detectImportOptions
Robin Nilsson
am 17 Okt. 2022
Stephen23
am 17 Okt. 2022
Robin Nilsson
am 17 Okt. 2022
Akzeptierte Antwort
Weitere Antworten (1)
Kevin Holly
am 17 Okt. 2022
0 Stimmen
I would suggest using the Import Data button found on the toolstrip.

After selecting the Excel spreadsheet to open, it should give you a preview and show what cells are unimportable. By default these cells are converted to NaN values. This could help you resolve the problem.
3 Kommentare
Robin Nilsson
am 17 Okt. 2022
Robin Nilsson
am 17 Okt. 2022
dpb
am 17 Okt. 2022
The import options object has ways to handle those as well; you can either use the default missing value and get the NaN or have any records with missing data skipped entirely, or a plethora of other options.
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


