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');
% ===============================================================
相关推荐
chhttty3 小时前
Design Verifier检查:整型数溢出检查与修复
matlab·simulink
tryCbest7 小时前
Excel常用公式(WPS vs Office)
excel·wps
吃好睡好便好7 小时前
判断函数的使用
学习·算法·matlab·生活·判断函数
hu9245195598 小时前
Matlab保护源代码—P文件和exe文件详细解析
开发语言·matlab
史上最甜的躯9 小时前
控制系统——基础、导论;以直流电机控制系统为例详解微分方程模型、拉普拉斯变换、传递函数模型的理论、推导及仿真
matlab·simulink·传递函数·控制系统·拉普拉斯·电机模型
taller_20009 小时前
【006】何时用 Python?何时用 Excel 公式?一文讲清
python·excel·公式·pie·py
2601_9499506310 小时前
Word、PDF、Excel题目怎么快速整理?
pdf·word·excel
Eiceblue1 天前
React 项目实战:用 JavaScript 合并多个本地 Excel 文件
前端·javascript·react.js·excel
lingchen19061 天前
用MATLAB r2010b和r2016b求解微分方程组
开发语言·算法·matlab
可编程芯片开发1 天前
基于李雅普诺夫算法的四旋翼无人机姿态跟踪控制系统simulink建模与仿真
matlab·无人机·制造·四旋翼无人机·李雅普诺夫·姿态跟踪控制