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');
% ===============================================================
相关推荐
tyatyatya9 小时前
MATLAB中进行视觉检测入门教程
开发语言·matlab·视觉检测
2zcode1 天前
基于Matlab可见光通信系统中OOK调制的误码率性能建模与分析
算法·matlab·php
星空的资源小屋1 天前
Digital Clock 4,一款免费的个性化桌面数字时钟
stm32·单片机·嵌入式硬件·电脑·excel
听情歌落俗1 天前
MATLAB3-1变量-台大郭彦甫
开发语言·笔记·算法·matlab·矩阵
揭老师高效办公1 天前
在Excel和WPS表格中批量删除数据区域的批注
excel·wps表格
我是zxb1 天前
EasyExcel:快速读写Excel的工具类
数据库·oracle·excel
XIAOYU6720131 天前
金融数学专业需要学哪些数学和编程内容?
开发语言·matlab·金融
听情歌落俗1 天前
MATLAB3-2数据存储-台大郭彦甫
开发语言·数学建模·matlab·矩阵
辣香牛肉面1 天前
[Windows] 搜索文本2.6.2(从word、wps、excel、pdf和txt文件中查找文本的工具)
word·excel·wps·搜索文本
ljf88382 天前
Java导出复杂excel,自定义excel导出
java·开发语言·excel