A series of functions "go" in MATLAB for operations such as file directories

Source: Internet
Author: User

From:http://www.ilovematlab.cn/thread-164384-1-1.html

1.Filesep
Used to return the directory delimiter for the current platform, Windows is a backslash (\), and Linux is a slash (/).
2.FullFile
Used to concatenate a number of strings into a full path. For example:
>> f=fullfile (' D: ', ' Matlab ', ' example.txt ')
F=d:\matlab\example.txt
(In Windows, "D:\" represents the D drive, "D:" means directory)
3.Fileparts
Used to split a full file name into 4 parts: path, file name, extension, version number. For example:
>> f=fullfile (' D: ', ' Matlab ', ' example.txt ');
>>[pathstr,name,ext,versn]=fileparts (f)
Pathstr=d:\matlab
Name=example
Ext=.txt
Versn= "
4.Pathsep
Returns the path delimiter for the current platform. Windows is a semicolon (;), Linux is a colon (:).
5.exist
Can be used to determine whether a directory or file exists, and different return values have different meanings. For example:
>> f=fullfile (' D: ', ' Matlab ', ' example.txt ');
>>exist (f)
ans=2
>>exist (' D:\Matlab ')
Ans =7
6.which
You can get its full path through a function or script name, as well as handle overloaded functions, such as:
>> which abs (0)
C:\MATLAB7\toolbox\matlab\elfun\ @double \abs.bi% double method
>> which abs (single (0))
C:\MATLAB7\toolbox\matlab\elfun\ @single \abs.bi% single method
7.Isdir
Determine if a path represents a directory, for example:
>> p= ' D:\Matlab ';
>> f=fullfile (P, ' example.txt ');
>> Isp=isdir (P)
Isp=1
>> Isf=isdir (f)
Isf=0
8.dir
Used to list the contents of a directory, the return value is a struct array type, which contains the following parts: name: filename of the file or directory, date: Date modified; bytes: file size; Isdir: Whether it is a directory. For example:
>> p= ' D:\Matlab ';
>>files=dir (P)
Files =
8x1 struct array with fields:
Name
Date
bytes
Isdir
9.CD
Used to toggle the current working directory. For example:
>>CD (' c:/toolbox/matlab/demos ')% switch current working directory to Demos
>>CD. % switch current working directory to MATLAB
10.pwd
The path used for the current working directory. For example:
>> pwd
Ans =c:\matlab7\work
11.Path
The operation to use for the search path. For example:
>>path% query All current search paths (Matlabpath)
>>p=path% The current search path exists in the string variable p
>>path (' NewPath ')% sets the current search path to NewPath
>>path (Path, ' NewPath ')% adds a new directory to the path NewPath
>>path (' NewPath ', path)% pre-adds a new directory to the current search path Nespath
12.AddpathAndRmpath
Used to add and remove the MATLAB search path. For example:
>>addpath (' directory ')% joins full path directory to the top of the current search path
>>rmpath
13. What
Used to show which MATLAB files exist in a directory, and if you enter the full path, you can list the files in the specified directory. For example:
>>what
>>what dirname
>>what (' dirname ')
Where DirName is the name of the path to find, the path in the MATLAB search path, there is no need to enter the full name, only enter the last or last level two is enough.
14.PATH2RC
Saves the current MATLAB search path to the pathdef.m file.

A series of functions "go" in MATLAB for operations such as file directories

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.