| MATLAB® | ![]() |
As an alternative to the what function, use the Current Directory browser.
what
what dirname
what classname
what packagename
s = what('dirname')
what lists the path for the current working directory, and all files and directories related to MATLAB found in the working directory. Files listed are M, MAT, MEX, MDL, and P-files. Directories listed are all class and package directories.
what dirname lists path, file, and directory information for directory dirname. If this directory is on the MATLAB search path, it is not necessary to enter the full path to dirname. The last one or two components of the path are sufficient.
what classname lists path, file, and directory information for method directory @classname. For example, what cfit lists the MATLAB files and directories in toolbox/curvefit/curvefit/@cfit.
what packagename lists path, file, and directory information for package directory +packagename. For example, what commsrc lists the MATLAB files and directories in toolbox/comm/comm/+commsrc.
s = what('dirname') returns the results in a structure array with the fields shown in the following table.
Field | Description |
|---|---|
path | Path to directory |
m | Cell array of M-file names |
mat | Cell array of MAT-file names |
mex | Cell array of MEX-file names |
mdl | Cell array of MDL-file names |
p | Cell array of P-file names |
classes | Cell array of class directories |
packages | Cell array of package directories |
List the files in toolbox/matlab/audiovideo:
what audiovideo M-files in directory matlabroot\toolbox\matlab\audiovideo Contents avifinfo sound audiodevinfo aviinfo soundsc audioplayerreg aviread wavfinfo audiorecorderreg lin2mu wavplay audiouniquename mmcompinfo wavread aufinfo mmfileinfo wavrecord auread movie2avi wavwrite auwrite mu2lin avgate prefspanel MAT-files in directory matlabroot\toolbox\matlab\audiovideo chirp handel splat gong laughter train MEX-files in directory matlabroot\toolbox\matlab\audiovideo winaudioplayer winaudiorecorder Classes in directory matlabroot\toolbox\matlab\audiovideo audioplayer avifile audiorecorder mmreader
Obtain a structure array containing the MATLAB file names in toolbox/matlab/general:
s = what('general')
s =
path: 'matlabroot:\toolbox\matlab\general'
m: {89x1 cell}
mat: {0x1 cell}
mex: {2x1 cell}
mdl: {0x1 cell}
p: {'callgraphviz.p'}
classes: {'char'}
packages: {0x1 cell}
Find the supporting M-files for one of the packages in the Communications Toolbox product:
p1 = what('comm');
p1.packages
ans =
'commdevice'
'crc'
'commsrc'
p2 = what('commsrc');
p2.m
ans =
'abstractJitter.m'
'abstractPulse.m'
'combinedjitter.m'
'diracjitter.m'
'periodicjitter.m'
'randomjitter.m'dir, exist, lookfor, mfilename, path, which, who
Managing Files and Working with the Current Directory
![]() | weekday | whatsnew | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |