1

I'm creating my own function in Matlab and I want to be able to display it like so below, when I type 'lookfor'.

>> lookfor mean
mean                           - Average or mean value.
msfun_metronomean              - METRONOMANIMATION S-function for making metronomean animation.
mameannorm                     - normalizes microarray data by dividing by global mean.
distfcm                        - Distance measure in fuzzy c-mean clustering.
fcm                            - Data set clustering using fuzzy c-means clustering.
initfcm                        - Generate initial fuzzy partition matrix for fuzzy c-means clustering.
stepfcm                        - One step in fuzzy c-mean clustering.

I've heard it can be done by typing a line directly below the declaration of the function as can be seen below:

function [outputArgs] = TestFunction(inputArgs)
%TESTFUNCTION Summary of this function goes here

However I've tried this and it still doesn't appear in the list of lookups?

Any help would be greatly appreciated.

Thanks in advance!

edwoollard
  • 12,245
  • 6
  • 43
  • 74
  • 1
    Is your function on the search path? What does `which -all mean` return? When I create a file `mean.m` and add it to the path, `lookfor mean` works fine. – StrongBad Oct 19 '13 at 19:04

2 Answers2

0

It is not clear what you have done. For a function like

function [outputArgs] = TestFunction(inputArgs)
%TESTFUNCTION Summary of this function goes here

I would not expect lookfor mean to find it. The documentation of lookfor is pretty clear

lookfor topic searches for the string topic in the first comment line (the H1 line) of the help text in all MATLAB® program files found on the search path. For all files in which a match occurs, lookfor displays the H1 line.

lookfor topic -all searches the entire first comment block of a MATLAB program file looking for topic.

If you want lookfor mean to find your function you need to have the H1 line include the word "mean"

function [outputArgs] = TestFunction(inputArgs)
%TESTFUNCTION Summary of this function goes here (mean)

Then lookfor mean works fine.

StrongBad
  • 869
  • 6
  • 16
  • function [outputArgs] = TestFunction(inputArgs) %TESTFUNCTION Summary of this function goes here. That was just an example online, I hadn't tailored it inside my question, sorry for the confusion. – edwoollard Oct 19 '13 at 18:50
0

I'm not sure exactly what I changed but it now works now. I'm sure it was something to do with the file path that the project was stored in. Thanks for your help though guys.

edwoollard
  • 12,245
  • 6
  • 43
  • 74