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');
% ===============================================================
相关推荐
云只上7 小时前
前端插件使用xlsx-populate,花样配置excel内容,根据坐添加标替换excel内容,修改颜色,合并单元格...。
excel
小哥山水之间8 小时前
在 Python 中操作 Excel 文件
开发语言·python·excel
blog_wanghao9 小时前
C#: 创建Excel文件并在Excel中写入数据库中的数据
数据库·c#·excel
机器学习之心13 小时前
机器人路径规划 | 基于极光PLO优化算法的机器人三维路径规划Matlab代码
算法·matlab·机器人·三维路径规划
IT猿手16 小时前
2025最新智能优化算法:改进型雪雁算法(Improved Snow Geese Algorithm, ISGA)求解23个经典函数测试集,MATLAB
数据库·人工智能·算法·机器学习·matlab
游客52016 小时前
自动化办公|通过xlwings进行excel格式设置
python·自动化·excel
喝西瓜汁的兔叽Yan17 小时前
第三方库XLSX: 前端上传excel文件,并对excel文件内容做校验。
前端·excel·xlsx
刘_sy1 天前
使用EasyExcel和多线程实现高效数据导出
java·excel·easyexcel·批量导出excel
studyer_domi1 天前
matlab质子磁力仪传感器线圈参数绘图
人工智能·matlab
PowerBI学谦2 天前
Copilot:Excel中的Python高级分析来了
python·excel·copilot