首页 > 其他 > 详细

MATLAB基本操作(七):有关文件路径的几个函数在编程中的作用

时间:2014-01-21 00:44:10      阅读:459      评论:0      收藏:0      [点我收藏+]
有关文件路径的几个函数在编程中的作用
Last Edit 2014/1/16
1,genpath: (gen=generate,顾名思义就是一个产生路径的函数,这个路径须存在)
genpath
genpath directory
p = genpath(‘directory‘)

>>genpath
其结果为 C:\Program Files\MATLAB\R2009a\toolbox;C:\Program Files\MATLAB\R2009a\toolbox\aero;....
                (本人机器上的MATLAB2009a)
>>path=genpath(‘D:\Code\‘)% 本人D盘的一个文件夹,如图
结果:显示这个路径下所有的文件夹
D:\Ccode;
D:\Ccode\OpenCV_test;
D:\Ccode\OpenCV_test\Debug;
D:\Ccode\OpenCV_test\OpenCV_test;
D:\Ccode\OpenCV_test\OpenCV_test\Debug;
D:\Ccode\OpenCV_test\images;D:\Ccode\Opencv_Event;
D:\Ccode\Opencv_Event\Debug;D:\Ccode\Opencv_Event\Opencv_Event;
D:\Ccode\Opencv_Event\Opencv_Event\Debug;
D:\Ccode\STL;
D:\Ccode\STL\Debug;
D:\Ccode\STL\STL;
D:\Ccode\STL\STL\Debug;
bubuko.com,布布扣

2,addpath(),添加一条路径,一般会和genpath联合使用
>>addpath(genpath(‘D:\Code\‘))
bubuko.com,布布扣
3,fullfile() 构造一条路径
path=fullfile(dir1,dir2,...,filename);
f = fullfile(‘C:‘, ‘Applications‘, ‘matlab‘, ‘myfun.m‘)
f =
C:\Applications\matlab\myfun.m

4,fileparts,将一条路径分成几个部分,如下例子所示
file = ‘\home\user4\matlab\classpath.txt‘;
[pathstr, name, ext, versn] = fileparts(file)

pathstr =
   \home\user4\matlab
name =
   classpath
ext =
   .txt
versn =
     ‘‘

从参考文档上搞来的,方便自己学习~~~~


MATLAB基本操作(七):有关文件路径的几个函数在编程中的作用

原文:http://blog.csdn.net/jxlijunhao/article/details/18366223

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!