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');
% ===============================================================
相关推荐
菜鸟~noob2333 小时前
【电子战】第08篇:多普勒测向的工程实现与优化【含matlab代码】
开发语言·matlab
菜鸟~noob2333 小时前
【电子战】第06篇:干涉仪与相位差测向【含matlab代码】
开发语言·matlab
鲲穹AI种草10 小时前
Excel 表格批量处理与数据整理,多款表格工具能力客观记录
excel·表格处理
菜鸟~noob23310 小时前
【电子战】测向精度极限——克拉美-罗下限(CRLB)与误差分析【含matlab代码】
开发语言·matlab
cspttty13 小时前
2026秋招供应链分析师技能栈:SQL、Excel、BI与业务分析
数据库·sql·excel
路径规划66615 小时前
(MATLAB代码) 船舶轨迹聚类:K-means 算法(260912)
算法·matlab·kmeans
matlab代码1 天前
基于matlab数字图像处理的指纹识别系统【源码68期】
开发语言·matlab
matlab代码1 天前
基于matlab的水果识别系统(苹果香蕉菠萝梨桃子)【源码65期】
开发语言·matlab
matlab代码1 天前
基于matlab自助水果超市水果识别收费系统(GUI界面)【源码67期】
开发语言·matlab
matlab代码1 天前
基于matlab数字图像处理的指纹识别系统 点线特征(GUI界面)【源码69期】
开发语言·matlab