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');
% ===============================================================
相关推荐
娃乐呵2 小时前
免费的大批量Excel文档大模型处理数据工具
语言模型·大模型·excel·数据处理
fie88894 小时前
基于MATLAB的多幅图像拼接
人工智能·计算机视觉·matlab
Eiceblue5 小时前
使用 Python 写入多类型数据至 Excel 文件
开发语言·python·excel
蹦蹦跳跳垂耳兔6 小时前
Excel创建组妙用隐藏
excel
Evand J7 小时前
【MATLAB免费例程】多无人机,集群多角度打击目标,时间与角度约束下的协同攻击算法,附下载链接
算法·matlab·无人机
开开心心_Every8 小时前
无广告干扰:简单好用文字LOGO设计工具
xml·java·网络·数据库·华为od·华为云·excel
简简单单做算法8 小时前
基于WOA鲸鱼优化CNN-BiLSTM网络模型的多输入单输出回归预测算法matlab仿真
matlab·回归预测·cnn-bilstm·woa-cnn-bilstm·鲸鱼优化
cici158748 小时前
基于高斯混合模型(GMM)的说话人识别系统MATLAB实现
开发语言·人工智能·matlab
崇山峻岭之间8 小时前
Matlab学习记录11
开发语言·学习·matlab
bu_shuo8 小时前
GUI_Syre报错问题解决
matlab·synrm·syr-e