Matlab cannot read string data
古いコメントを表示
Hi everyone,
please help me,
i have a xls file with 6 column. First column is string type and others are numeric. i don't know why i cant read the first column data with 'xlsread'. maybe because it is string. is there any way to read my first column?
Thankyou
1 件のコメント
Star Strider
2020 年 4 月 28 日
The xlsread funciton has three possible outputs. The first is numeric data, the second is character data, and the third is a cell array of everything in the file. Return all the outputs, then experiment with how best to extract the non-numeric data you want.
回答 (1 件)
Adam Danz
2020 年 4 月 28 日
0 投票
Straight out of the documentation
num = xlsread(filename) reads the first worksheet in the Microsoft® Excel® spreadsheet workbook named filename and returns the numeric data in a matrix.
7 件のコメント
joni nababan
2020 年 4 月 28 日
Adam Danz
2020 年 4 月 28 日
I dont know why the first column is 'NaN'
I explained why in my answer. This line below is only reading in numeric data.
dataExcel = xlsread(fullfile(path,filename),'sheet1','A2:F50')
joni nababan
2020 年 4 月 28 日
Adam Danz
2020 年 4 月 28 日
As I mentioned in my answer, try using readtable. There's a link to that function in the answer.
Star Strider also mentioned the additional outputs to xlsread that could solve the problem.
If you get stuck, share the updated section of code that reads in the data.
joni nababan
2020 年 4 月 29 日
Walter Roberson
2020 年 4 月 29 日
dataExcel = readtable(fullfile(path,filename), 'sheetname', 'sheet1', 'range', 'A2:F50', 'readvariablenames', false);
joni nababan
2020 年 4 月 29 日
カテゴリ
ヘルプ センター および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
