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');
% ===============================================================
相关推荐
slandarer1 小时前
MATLAB | R2026a 更新了哪些有趣的新东西?
开发语言·数据库·matlab
gihigo19982 小时前
MATLAB地震面波数值模拟方案
开发语言·matlab
可编程芯片开发2 小时前
基于Voronoi自适应分区的Qlearning强化学习粒子群算法的海上风电场电气系统拓扑优化matlab仿真
matlab·voronoi·qlearning·拓扑优化·自适应分区·海上风电场
关岭风尘3 小时前
Matlab/Simulink - BLDC直流无刷电机仿真基础教程(九) - BLDC电机滑行状态低占空比启动波形分析
matlab·电机控制·bldc仿真·电机续流·滑行启动
开开心心就好4 小时前
系统重装前必备的智能驱动备份工具
windows·计算机视觉·计算机外设·excel·模块测试·csdn开发云·威胁分析
Not Dr.Wang4224 小时前
基于matlab的控制系统奈氏图及其稳定性分析
数据结构·算法·matlab
向宇it17 小时前
php高性能的导出excel读写扩展——xlswriter,比传统的Spreadsheet要快很多
php·excel·xlswriter
machnerrn20 小时前
matlab实现直流伺服电机 PID 控制系统仿真系统(含源码+资料报告+说明文档等)
开发语言·matlab
破阵子443281 天前
MATLAB 下载安装教程
matlab
yanweijie03171 天前
对比VLOOKUP、XLOOKUP、INDEX+MATCH三大查找函数
excel