Unable to read strings (I get NaN) in the excel file imported into Matlab

3 ビュー (過去 30 日間)
Faichal Ayeva
Faichal Ayeva 2020 年 1 月 2 日
回答済み: Amit 2020 年 1 月 2 日
I am importing an Excel file that has both strings and numeric values. Eventhough I can see the springs value during the importation (using the import data tool), I m unable to see those strings after I run my code an extract the rows I want. I see NaN instead of the string values. Please, what should I do? Thank you!!

回答 (2 件)

Lucademicus
Lucademicus 2020 年 1 月 2 日
I have made an Excel file with a column containing numbers and strings.
mat.PNG
The result of importing depends on what data you tell MATLAB to expect, and how to treat other data types.
In this preview, I have highlighted how MATLAB's tells me a value will be treated as NaN:
mat3.PNG
If you want to have mixed numbers and strings, you should choice Cell Array as Output Type (whereas it is Table, in my example).

Amit
Amit 2020 年 1 月 2 日
Import the exel data with option cell array output type, not as Numeric matrix.

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by