MATLAB: How to call a function in another mfile from main program in matlab

In my project I have to extract dominant gray level run length features. From my main program I have to call the following function located in another mfile.
->function [GLRLMS,SI]= grayrlmatrix(varargin).
when I execute the main function the following error is occuring
->Undefined function 'grayrlmatrix' for input arguments of type 'double'.
->Error in domimain (line 53) [GLRLMS,SI] = grayrlmatrix(wave2);
Please help me to rectify the error. Thank you.

Best Answer

You can't call a function in another m-file unless it's the main one in that m-file, in other words, the top function in the file - the one with the same name as the file. You can't call any subfunctions that are listed second, third, etc. that the file is not named for. If you need to do that, you can create a class. Look up in the help how to create a class file.
Related Question