请参阅xlsread的文档; 你必须加载所有数据:
来自matlab doc:例子
从myExample.xlsx请求数字数据,文本和未处理(原始)数据的副本:
[ndata, text, alldata] = xlsread('myExample.xlsx')
ndata =
1 2 3
4 5 NaN
7 8 9
text =
'First' 'Second' 'Third'
'' '' ''
'' '' 'x'
alldata =
'First' 'Second' 'Third'
[ 1] [ 2] [ 3]
[ 4] [ 5] 'x'
[ 7] [ 8] [ 9]
Run Code Online (Sandbox Code Playgroud)
如果您知道标题在哪些单元格中,您还可以指定要从Excel文件中读取的范围:
[~, headers, ~ ] = xlsread('myExample.xlsx','A1:C1');
Run Code Online (Sandbox Code Playgroud)
这给出了(对于^^上面使用的示例数据):
headers =
'First' 'Second' 'Third'
Run Code Online (Sandbox Code Playgroud)