xlswrite(filename,A,sheet,xlRange)
filename不能是str格式,需要是cell格式
% ===== 写入字符串 ================================================
% 注意事项:Str需要是Cell格式,否则一个字母占一格
% ===============================================================
Str = {‘abc’};
xlswrite('flux.xlsx',Str,'sheet4','A1');
% ===== 写入数组 =================================================
% 只需给出 arr(1,1) 对应的 'xlRange',一个数字一个格子
% ===============================================================
arr = rand(5);
xlswrite('flux.xlsx',arr,'sheet4','A2');
[num,txt,raw] = xlsread(filename,A,sheet,xlRange)
- num:返回 [ 数值 ] 字段 —— double格式
- txt:返回 [ 文本 ] 字段 —— cell格式
- raw:返回 [ 数值、文本 ] 字段 —— cell格式
% ===== read excel data 【Example from matlab help]】 ============
[num,txt,raw] = xlsread('myExample.xlsx')
num = % num 中顺序下的字符以NAN表示
1 2 3
4 5 NaN
7 8 9
txt = % txt 中数值不读取,以''表示
'First' 'Second' 'Third'
'' '' ''
'' '' 'x'
raw =
'First' 'Second' 'Third'
[ 1] [ 2] [ 3]
[ 4] [ 5] 'x'
[ 7] [ 8] [ 9]
% ===============================================================
% ===== 只读取txt ================================================
[~,txt,~] = xlsread('flux.xlsx','sheet4','A1');
% ===============================================================
sheetnames(‘*.xlsx’);
- 会得到 ‘string’ 格式的数组