Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to obtain list of functions of a package that is installed in octave?

Tags:

octave

after one installs a package, what is the command to find what functions are in that package?

for example, I have the control package installed. But how find help on this package such as what functions it includes and such, like with Matlab?

does one have to go to the http://octave.sourceforge.net/ web site each time to find out? Can one find this information from inside octave?

I find Matlab help much better and easier to use than octave.

like image 327
Robert H Avatar asked Jan 15 '23 21:01

Robert H


2 Answers

Use pkg describe -verbose control to get all info from the control package.

like image 139
carandraug Avatar answered May 10 '23 01:05

carandraug


Octave function displaying package help

I wrote a short octave function, that solves your problem: It creates a dialogue box to display all functions in a package. After selecting one function it will display it's the help text in a message box. Just save the following octave function to a file named pkghelp.m and run it by typing
pkghelp packagename.

Example

The following will display the function overview for package 'io':
pkghelp io

Source Code

% Script to display functions and help on functions for a package
function pkghelp(pkgname)

  % Get functions for this package
   des = pkg('describe','-verbose',pkgname);
   % Get first element
   des = des{1};

   if isempty(des)
     error('pkghelp:unknownPackage','Package "%s" was not found!',pkgname);
   endif
   
   % Create a dialog with functions
   pname = des.name;
   pvers = des.version;
   pdesc = des.description;
   
   % Number of categories
   ncat = numel(des.provides);
   list = cell(1,1);
   cnt=1;
   for i=1:ncat
     % Store category name
     list(cnt) = ['--(* ',des.provides{i}.category,' *)--'];
     % Number of functions
     nfunc = numel(des.provides{i}.functions);
     % Append functions in category
     list(cnt+1:cnt+nfunc) = des.provides{i}.functions(:);
     % Update counter
     cnt = cnt+1+nfunc;
   endfor

  ok=1;
  while ok==1  
    % Create dialog
    [sel, ok] = listdlg ('ListString', list,...
                     'SelectionMode', 'Single', ...
                     'ListSize',[300,600],...
                     'Name',pname,...
                     'PromptString','List of available functions');

    
    if (ok==1)
     % Selected function name
     selfun = list{sel};
     % Not a category?
     if selfun(1) ~= '-'
       % assure that package is loaded for help
       pkg('load',pkgname);
       % Get help text for selected function
       doc = help(selfun);
       % Open dialog with help text display
       msgbox(doc,[pname,'/',selfun],'help');
     endif
    endif
  endwhile
                     
endfunction

octave

like image 35
Georg W. Avatar answered May 10 '23 01:05

Georg W.