image thumbnail

LOOK4

version 1.1.0.1 (15.3 KB) by jiro
LOOKFOR substitute that uses a database for quick searching of MATLAB® files.

2.8K Downloads

Updated 01 Sep 2016

View License

Editor's Note: This file was a File Exchange Pick of the Week

LOOK4 Quick-search M-files with keywords using a database.
LOOK4 ABC XYZ ... looks through a database of help files (H1 lines in m-files) for keywords ABC, XYZ, ... There can be as many keywords as desired. For all files in which a match occurs, the H1 line is displayed. CLASS METHODS will be indented by one space, and PRIVATE function will be indented by two spaces.

LOOK4 is very similar to LOOKFOR, except that it searches through a database file named mfileDatabase#.mat (where # is the version number), so it is much faster. Also, unlike LOOKFOR it accepts multiple keywords. The search is case-insensitive.

mfileDatabase#.mat is created the first time LOOK4 is executed. It catalogs helt texts of all m-files in the MATLABPATH (including class methods and private functions). The database file is stored in the same directory as this file. The generation of the database file may take a few minutes depending on the number of m-files and the speed of the computer.

LOOK4 ABC XYZ ... -all : searches the entire first comment block of m-files.
LOOK4 ... -link : displays the results with hyperlinks to full help texts

LOOK4 -new : re-creates the database file.
LOOK4 -new -noverbose : does not show the name of the directory in progress.
LOOK4 -update : updates the database file for the current directory. This is useful for updating personal m-files.
LOOK4 -autoupdate : sets up auto-updating feature.

How Auto-Updating of Database Works:
The database can be set to tomatically update (re-hash) daily or weekly. LOOK4 accomplishes this by creating a function called look4_autoUpdateFcn.m that gets run during startup (The call is appended to startup.m. If startup.m does not exist, it creates one). This function creates a TIMER object (tagged 'look4AutoUpdateTimer') that gets executed at the appropriate time and interval. Matlab needs to be running at the time of execution. If Matlab is launched after the scheduled update time, then the timer will be scheduled to execute at the next update time.
LOOK4 also checks the age of the database file (by checking the modification date), and gives a warning when 2 weeks has passed since the last modification. This feature creates a dummy file "mfileDatabase#_vt.txt" which is used to store the time when the warning was displayed.

[H, P] = LOOK4('ABC', 'XYZ', ...) returns the H1 lines and the paths of the corresponding m-files, respectively.

LOOK4 by itself invokes a GUI version of the search program. The GUI incorporates a "key stroke" search feature. Each key stroke updates the search result, but only after 0.5 seconds of non-keypress. This allows fast, continuous typing. Only alphabets and numbers (and quotes) are allowed in the GUI version. Click on results list, or use arrow keys to navigate through results. The full help text is displayed in the bottom panel.

Example:
look4 root locus
look4 root locus -all

See also LOOKFOR, HELP, DOC.

This is a remake of my WHEREIS code (also found in FEX).

Cite As

jiro (2021). LOOK4 (https://www.mathworks.com/matlabcentral/fileexchange/9963-look4), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R13SP1
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!