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');
% ===============================================================
相关推荐
行秋40 分钟前
MATLAB 中的两大电力仿真库:Simscape Electrical(蓝色库) vs SimPowerSystems(黑色库)
开发语言·matlab
机器学习之心1 小时前
CEEMD-KPCA-PINN多变量时序光伏功率预测!互补集合经验模态分解+核主成份降维+物理信息神经网络,MATLAB代码
神经网络·机器学习·matlab·多变量时序光伏功率预测·物理信息神经网络
英英_1 小时前
如何在MATLAB中进行数据可视化
matlab·信息可视化·数据分析
wtsolutions2 小时前
MCP Service Integration - Excel to JSON for AI and Automation
人工智能·json·excel
guygg8810 小时前
一级倒立摆MATLAB仿真程序
开发语言·matlab
wtsolutions12 小时前
JSON to Excel Add-in - Seamless Integration Within Excel
json·excel
wtsolutions13 小时前
Getting Started with JSON to Excel Web App - Convert in Seconds
json·excel·web app
wtsolutions16 小时前
Using the JSON to Excel API - Programmatic Access for Developers
json·excel
qq_4351395716 小时前
EasyExcel(FastExcel)Excel导出功能 技术文档
excel
wtsolutions19 小时前
Understanding JSON Formats - What JSON to Excel Supports
json·excel