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');
% ===============================================================
相关推荐
灵析表格4 小时前
灵析表格财务函数深度实用性分析与实操教程
开发语言·ai·json·excel·wps
杰夫(简道云个人搭建)9 小时前
SAAS系统应该先解决业务问题,再优化体验
数据库·人工智能·低代码·excel·个人开发
民乐团扒谱机1 天前
【超详解】量子克拉美罗下界QCRB:时延估计精度极限推导+MATLAB多场景绘图实战
开发语言·机器学习·matlab·量子力学·qcrb
AI导出鸭1 天前
怎么让豆包做表格?AI导出鸭苹果版将豆包输出的管道表格智能解析为二维结构,一键导出为Excel或Word标准表格。
人工智能·chatgpt·word·excel·ai导出鸭
水桶学习吧_2 天前
MTMD人致振动MATLAB-SAP2000协同优化
matlab·mtmd·sap2000
ι:2 天前
MATLAB 与 Python 搭建无人机地面站:优势、劣势与选型逻辑
python·matlab·无人机
福大大架构师每日一题2 天前
2026年8月TIOBE编程语言排行榜,Go语言排名第14,Rust语言排名10。MATLAB 的日子似乎屈指可数了。
开发语言·matlab·rust
吃好睡好便好2 天前
MATLAB仿真框图4
开发语言·matlab·仿真·分段函数
RickyWasYoung2 天前
【matlab】坐标图四角畸变矫正代码
开发语言·matlab
NoteStream2 天前
MATLAB散点投影线型热图(linearheatmap)完整可复用代码
开发语言·matlab