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');
% ===============================================================
相关推荐
智航GIS42 分钟前
9.3 Excel 自动化
python·自动化·excel
Evand J1 小时前
MATLAB例程【二维,UKF,速度滤波】DVL与IMU的融合例程,模拟速度和惯导的融合,适用于二维平面、非线性的运动轨迹
开发语言·matlab·滤波·定位
骑着蜗牛闯宇宙1 小时前
TP8上传Excel地址数据批量标注到高德地图
数据库·php·excel
魅惑青花瓷1 小时前
【EXCEL动态获取数据范围并整列自动填充公式】
excel
fie88891 小时前
基于MATLAB的3D心形图与玫瑰花图案实现
数学建模·matlab·3d
崇山峻岭之间14 小时前
Matlab学习记录18
开发语言·学习·matlab
zbguolei18 小时前
上传 Excel 文件进行数据库比对--增加导出功能
数据库·excel
weixin_3077791321 小时前
MATLAB动态演示流体扩散仿真模拟的简单例子
开发语言·matlab
!chen1 天前
Excel高性能异步导出完整方案
excel