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 小时前
【图像亮度、对比度调整,直方图均衡化及图像平滑】
图像处理·人工智能·opencv·算法·计算机视觉·matlab·嵌入式
机器学习之心4 小时前
分类预测 | Matlab实现GWO-LSSVM灰狼算法优化最小二乘支持向量机多特征分类预测
算法·matlab·分类·gwo-lssvm
Evand J4 小时前
【MATLAB代码】RSA加密和解密例程
开发语言·算法·matlab
Smilecoc13 小时前
excel单、双字节字符转换函数(中英文输入法符号转换)
excel
Terry_trans13 小时前
工作中遇到的EXCEL小问题:多行有间隔符的合并
excel
舊時王謝堂前燕13 小时前
Vue2+Element实现Excel文件上传下载预览【超详细图解】
excel
Matlab仿真实验室14 小时前
基于Matlab实现倒立摆仿真程序
开发语言·matlab·倒立摆仿真程序
如意机反光镜裸14 小时前
一键导出数据库表到Excel
数据库·excel·导出
XMYX-017 小时前
用Python3脚本实现Excel数据到TXT文件的智能转换:自动化办公新姿势
python·自动化·excel
graphyer18 小时前
Google sheet 复制excel内容自动合并单元格问题
excel·google sheet