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');
% ===============================================================
相关推荐
RaLi和夕5 小时前
Matlab求传递函数的零极点及增益并绘制零极点图 2
matlab
刻BITTER8 小时前
用EXCEL 将单色屏幕的Bitmap 字模数据还原回图形
单片机·嵌入式硬件·excel·arduino
匿者 衍8 小时前
POI读取 excel 嵌入式图片(支持wps 和 office)
java·excel
天外天-亮8 小时前
Vue + excel下载 + 水印
前端·vue.js·excel
wuk99817 小时前
MATLAB双树复小波变换(DTCWT)工具包详解
人工智能·计算机视觉·matlab
机器学习之心17 小时前
PINN预测圆形区域内的二维声场MATLAB实现
matlab·pinn·二维声场
allbs20 小时前
spring boot项目excel导出功能封装——2.高级导出
spring boot·后端·excel
tyatyatya1 天前
如何在MATLAB中进行数据可视化?
matlab·信息可视化·数据分析
软件算法开发1 天前
基于秃鹰搜索优化的LSTM深度学习网络模型(BES-LSTM)的一维时间序列预测算法matlab仿真
深度学习·算法·matlab·lstm·时间序列预测·秃鹰搜索优化·bes-lstm
子不语1801 天前
Matlab(一)——绘图
开发语言·matlab