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');
% ===============================================================
相关推荐
kaikaile199512 小时前
基于MATLAB的直接序列扩频(DSSS)通信系统仿真实现
开发语言·matlab
aerror16 小时前
将sqlite3的表转成excel表
java·sqlite·excel
CodeCraft Studio17 小时前
国产化Excel开发组件Spire.XLS教程:Python将列表导出为CSV文件(含一维/二维/字典列表)
开发语言·python·excel·csv·spire.xls·列表导出为csv
guygg8817 小时前
Alpha稳定分布概率密度函数的MATLAB实现
开发语言·matlab
Dev7z1 天前
基于Matlab的数字基带通信系统仿真与性能分析
matlab·数字基带通信系统·单极性不归零码·双极性不归零码·单极性归零码·双极性归零码
侯得山1 天前
ExcelToKml(Excel版)
excel·谷歌地球·kml·exceltokml
机器学习之心1 天前
NGO-VMD北方苍鹰算法优化变分模态分解+皮尔逊系数+小波阈值降噪+信号重构,MATLAB代码
算法·matlab·重构·信号重构·ngo-vmd·皮尔逊系数·小波阈值降噪
简简单单做算法2 天前
基于球面透视投影模型的鱼眼图像校正算法matlab仿真
matlab·球面透视投影·鱼眼图像校正
侯得山2 天前
批量坐标转换(Excel版)
excel·坐标转换·地理坐标·cgcs2000·直角坐标
Emma歌小白2 天前
在 Excel 中要把数字补齐到固定长度
excel