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');
% ===============================================================
相关推荐
加成BUFF25 分钟前
MATLAB 基础命令合集:从入门到精通(环境、变量、矩阵、绘图全解析)
数据结构·matlab·矩阵
qq_546937271 小时前
office和WPS平替软件,可以打开Word_Excel_PPT
word·excel·wps
吃好睡好便好1 小时前
创建随机矩阵
开发语言·人工智能·线性代数·算法·matlab·矩阵
Teable任意门互动1 小时前
拆解 Teable 背后研发主体,开源多维表格平台实力与落地案例
开发语言·开源·excel·飞书·开源软件
吃好睡好便好1 小时前
用直接输入的方式创建矩阵
开发语言·人工智能·学习·线性代数·算法·matlab·矩阵
Cloud_Shy6181 小时前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(第十二章 用户定义函数 下篇)
python·plotly·数据分析·excel·numpy·pandas
吃好睡好便好10 小时前
用while循环语句求和
开发语言·学习·算法·matlab·信息可视化
吃好睡好便好12 小时前
用for循环语句求和
开发语言·人工智能·学习·matlab·学习方法
构建的乐趣14 小时前
Givens rotation matlab实验
matlab·linear algebra
Deep-w20 小时前
【MATLAB】基于 MATLAB/Simulink 的无刷直流电机(BLDC)转速控制模糊 PID 算法
开发语言·算法·matlab