MATLAB - excel 读取

matlab中excel 读取

  • [1. 写入excel文件 - xlswrite](#1. 写入excel文件 - xlswrite)
  • [2. 读取excel文件 - xlsread](#2. 读取excel文件 - xlsread)

1. 写入excel文件 - xlswrite

xlswrite(filename,A,sheet,xlRange)

javascript 复制代码
% ===== 写入字符串 ================================================
% 注意事项:Str需要是Cell格式,否则一个字母占一格
% ===============================================================
Str = {'abc'};
xlswrite('flux.xlsx',Str,'sheet4','A1');

% ===== 写入数组 =================================================
% 只需给出 arr(1,1) 对应的 'xlRange',一个数字一个格子
% ===============================================================
arr = rand(5);
xlswrite('flux.xlsx',arr,'sheet4','A2');

2. 读取excel文件 - xlsread

[num,txt,raw] = xlsread(filename,A,sheet,xlRange)

  • num :返回 [ 数值 ] 字段 ------ double格式
  • txt :返回 [ 文本 ] 字段 ------ cell格式
  • raw :返回 [ 数值、文本 ] 字段 ------ cell格式
javascript 复制代码
% ===== 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');
% ===============================================================
相关推荐
技术净胜3 小时前
MATLAB 环境搭建与认知实战教程:从下载安装到入门全解析教程
开发语言·matlab
bu_shuo4 小时前
Simulink保存为低版本模型文件
matlab·simulink
哆啦A梦15884 小时前
商城后台管理系统 03 Vue项目-实现表格导出EXCEL表格
前端·vue.js·excel
技术净胜4 小时前
MATLAB基本运算与运算符全解析
开发语言·matlab
xingzhemengyou14 小时前
python pandas操作excel
python·excel·pandas
aini_lovee4 小时前
使用BP神经网络进行故障数据分类的方法和MATLAB实现
神经网络·matlab·分类
listhi5205 小时前
matlab大规模L1范数优化问题
开发语言·matlab
小小心LOVE5 小时前
Vue3 安装和使用 vue-office来实现 Word、Excel 和 PDF 文件的预览
vue.js·word·excel
cyhysr5 小时前
oracle的model子句让sql像excel一样灵活2
sql·oracle·excel
jghhh015 小时前
基于 MATLAB 的光照不均匀图像增强
opencv·计算机视觉·matlab