Home > atmlab > handy > folder_of_fun.m

folder_of_fun

PURPOSE ^

FOLDER_OF_FUN Folder containing a given function

SYNOPSIS ^

function folder = folder_of_fun( funname, uplevels )

DESCRIPTION ^

 FOLDER_OF_FUN   Folder containing a given function

    The function returns the path of the folder where the specified function.
    The function *which* is used to locate thefunction *funname*.

    The optional argument *uplevels* can be used to directly move to some
    parant folder.

 FORMAT folder = folder_of_fun( funname[, uplevels] )

 OUT   folder   Path of folder
 IN    funname  Name of function
 OPT   uplevels Move up this number of levels, to reach a parent folder.
                Default is 0.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

folder_of_fun.m

SOURCE CODE ^

0001 % FOLDER_OF_FUN   Folder containing a given function
0002 %
0003 %    The function returns the path of the folder where the specified function.
0004 %    The function *which* is used to locate thefunction *funname*.
0005 %
0006 %    The optional argument *uplevels* can be used to directly move to some
0007 %    parant folder.
0008 %
0009 % FORMAT folder = folder_of_fun( funname[, uplevels] )
0010 %
0011 % OUT   folder   Path of folder
0012 % IN    funname  Name of function
0013 % OPT   uplevels Move up this number of levels, to reach a parent folder.
0014 %                Default is 0.
0015 
0016 % 2014-08-29   Created by Patrick Eriksson
0017 
0018 function folder = folder_of_fun( funname, uplevels )
0019 %
0020 if nargin == 1, uplevels = 0; end
0021 
0022 folder = fileparts( which( funname ) );
0023 
0024 for i = 1 : uplevels
0025   folder = fileparts( folder );
0026 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005