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');
% ===============================================================
相关推荐
曲折前进的小白1 天前
MATLAB2026a添加新的工具箱
matlab
m0_547486661 天前
《模式识别:使用MATLAB分析与实现》全套PPT课件
开发语言·matlab·模式识别
Evand J1 天前
【MATLAB例程|车联网6】考虑调头车流扰动与网联车辆实时感知信息的干线多交叉口 FAC-CV 全感应协调控制仿真与性能对比分析
开发语言·matlab·仿真·代码·车联网·智慧交通·车辆
aini_lovee1 天前
计算 HOG算子的典型 MATLAB 程序
开发语言·matlab
bubiyoushang8881 天前
ADMM(交替方向乘子法)算例
matlab
feifeigo1231 天前
matlab电力系统重构实现
开发语言·matlab·重构
许彰午1 天前
74_Python自动化办公之Excel操作
python·自动化·excel
E_ICEBLUE1 天前
在 Python 中快速锁定 Excel 单元格与行列
python·安全·excel
用户712122751265 天前
MATLAB 自动化 Excel 转 SLDD 数据字典完整方案(适配自定义 THBPackage 存储类)
matlab
ZhengEnCi6 天前
P2M-Matplotlib折线图完全指南-从数据可视化到趋势分析的Python绘图利器
python·matlab·数据可视化