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');
% ===============================================================
相关推荐
yunceqing5 小时前
从Excel调度到TMS平台:物流软件开发避坑清单
大数据·前端·网络·人工智能·excel·推荐算法
什仙5 小时前
Mathcad Prime 对比 Excel/MATLAB/Mathematica:核心优势速览
excel
快乐的哈士奇5 小时前
【Next.js实战②】Excel 派送表动态解析:表头识别与 FIELD_ALIASES 映射
前端·javascript·excel
我爱C编程5 小时前
基于BellHop模型的海底网络节点部署matlab模拟与仿真
matlab·bellhop·bellhop模型·海底网络节点部署
小白小宋5 小时前
【PUSCH番外篇】5G NR 相位补偿与频移校正:原理、流程与工程实现
算法·5g·matlab·信息与通信·信号处理
2zcode6 小时前
基于MATLAB语音信号变声算法设计与实现
算法·matlab·语音识别·变声算法
daols886 小时前
vue vxe-table 复制数据到 Excel:支持带表头复制
vue.js·excel·vxe-table
guygg8818 小时前
人行走作用下板的振动响应 MATLAB 仿真
开发语言·matlab
海兰19 小时前
【web应用】Excel 项目数据自动化分析系统(AI 驱动分析)详细设计与部署指南(附源代码)
前端·人工智能·自动化·excel
ji198594431 天前
MATLAB 求散点曲线斜率
开发语言·算法·matlab