matlab读取某一路径下的excel_Matlab读取Excel文件相关操作及示例

Matlab读取Excel文件相关操作及示例

1 Matlab文件夹相对路径设置

l Cd函数功能:Change current folder

Syntax:

cd(newFolder)

oldFolder = cd(newFolder)

cd

Description

cd(newFolder) changes the current folder to the string

newFolder.

oldFolder = cd(newFolder) returns the existing current

folder as a string to oldFolder, and then changes the

current folder to newFolder.

cd displays the current folder.

The newFolder string can be:

· A full or relative path.

· ../, which indicates one level up from the current

folder.

· Multiple strings of ../, which indicates multiple levels

up from the current folder.

· ./, which indicates a path relative to the current folder,

although without the ./, cd assumes that the path

is relative to the current folder.

l pwd: PWD Show (print) current working

directory.

PWD displays the current working directory.

S = PWD returns the current directory in the string S.

2 文件夹下的文件识别

%%%%%% 读取Excel文件

dirs=dir('c:\*.sys'); %

用你需要的目录以及文件扩展名替换。读取某个目录的指定类型文件列表,返回结构数组。

dircell=struct2cell(dirs)' ; %

结构体(struct)转换成元胞类型(cell),转置一下是让文件名按列排列。

filenames=dircell(:,1) % 第一列是文件名

3 Excel文件读取说明

l 读Excel文件(相关说明:doc xlsread)

l 写Excel文件(相关说明:doc xlswrite)

l 注:在写Excel文件时,每使用一次xlswrite,Excel文件都需要保存一次;若文件比较大,写的速度会很慢。为避免每次保存,可改写系统函数,等所有写的数据写好后,再进行保存,见以下Excel代码:

function

[WriteTime]=MyXlsWrite(FileName,data,SheetNames,range,FileSave)

% % 参考系统函数xlswrite,将数据批处理写入Excel文件中:

% % 主要功能࿱

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值