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');
% ===============================================================
相关推荐
破z晓1 小时前
javascript 导出excel表
开发语言·javascript·excel
机器学习之心5 小时前
CCD实验设计+SVM代理建模+改进NSGA-II工艺参数多目标优化,MATLAB代码
算法·支持向量机·matlab·多目标优化
Am-Chestnuts5 小时前
豆包多轮回答中的表格导出 Excel:编号、日期与长数字检查
excel
泛泛7辈6 小时前
通过matlab训练和验证深度学习的目标检测
深度学习·目标检测·matlab
hPw0eKIqD19 小时前
使用二次封装的Excel COM 组件操作Excel\WPS ET中的区域、行和列
excel·wps
daad7771 天前
记录matlab状态机demo
java·网络·matlab
冰心孤城1 天前
Excel: xls与xlsx格式转换排坑指南
java·前端·excel
吃好睡好便好1 天前
MATLAB中图像的线性变换
开发语言·图像处理·学习·计算机视觉·matlab
金豆呀1 天前
WPS批量提取Word文档内容生成固定格式Excel表格
word·excel·wps
吃好睡好便好1 天前
MATLAB中图像的对数变换
图像处理·学习·算法·计算机视觉·matlab