读取Excel:
xlsread('Excel路径+Excel名称')
如果Excel文件和编写程序的文件在同一文件夹,不需要填写路径。
例1:读取Excel
a=xlsread('工作簿1')
例2:读取指定的sheet
b=xlsread('工作簿1','sheet2')
例3:读取指定的sheet中的指定的行或列
c1=xlsread('工作簿1','sheet2','a1:a3')
c2=xlsread('工作簿1','sheet2','a1:c1')
例4:读取指定的sheet中的指定的区域
d=xlsread('工作簿1','sheet2','b2:c3')
写入Excel:
xlswrite('Excel路径+Excel名称',需要输入的矩阵的名字)
如果Excel文件和编写程序的文件在同一文件夹,不需要填写路径。
例5:写入Excel
test=[1 2 3;4 5 6;7 8 9];
xlswrite('工作簿2.xlsx',test)
例6:写入到指定的sheet
test=[1 2 3;4 5 6;7 8 9];
xlswrite('工作簿2.xlsx',test,'sheet2')