Ken & Mike on the MATLAB Desktop
June 8th, 2009
Using the cell mode toolbar
The MATLAB Editor is great because supports many different workflows and user styles. Even though I call myself an advanced MATLAB user, I have long since stopped being surprised when I find out about something that has been there forever and is quite blatant in the UI. There are just some things that I don’t need to use in my normal work, but may be quite useful to others. One such thing is the cell mode toolbar. If the toolbar is not already present in the editor, you can activate it from the menu: Cell -> Enable Cell Mode.
The first two items on the toolbar are the ones I use a lot. They are evaluate current cell (Ctrl+Enter) and evaluate cell and advance to next (Ctrl+Shift+Enter). This is great for live demos, where you can put a single concept (of multiple commands) in a cell and then step through a file one cell at a time. The demo workflow also fits nicely with publishing, where each step of the demo publishes into a separate section. Just remember that evaluating a cell evaluates the enclosed commands in the base workspace, which is not necessarily the same workspace as if the file were run regularly.
The next two sections of the toolbar have a textbox surrounded by either a “+,-” or a “x,%”. It’s not obvious what to do with these. If you place the caret in the editor next to a number or select a number, then the +,-,x,% buttons will light up. Pressing them will increment/decrement or multiply/divide the selected number by the amount in the box and reevaluate the current cell. This is good for tweaking a numerical parameter, such as a coefficient, tolerance, or number of iterations/interpolations. In this example I’m tweaking the peaks input, which produces a nice visual change on each increment.
The next two buttons %% are a little more obvious but their icons are subtly different. The first one has a plus “+” in the icon and clicking it inserts a new cell marker. It’s handy to have that for the mouse, but I find it faster to type “%%”. The second one provides you a dropdown list of the cells in your file, the same way the function dropdown provides a list of functions in the file.
And remember, you can always customize the buttons that show up on the cell mode toolbar: File -> Preferences -> Toolbars -> Editor Cell Mode.
By
Michael Katz
Mike is a developer on the MATLAB Desktop team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
13:12 UTC |
Posted in Editor, Preferences, Publish |
Permalink |
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
Leave a Reply
|
My favorite element of the cell mode toolbar is the “-+” part. Since I discovered the possibilities of this feature, I use it everytime I need to tune or debug a Simulink model.
By writing a simple script, I can change the value of a parameter (using the “-+ feature”), simulate the model using SIM, plot the results and see the effect. click, click, click, done. It speeds up things by 1000%.
Guy, great point. Simulink parameters are an excellent usage of this!
Hey Ken and Mike,
Whenever I present MATLAB in bootcamp mode (which is very often), I always highlight the utility of cell-mode editing. One of the benefits I point out is the vastly under-utilized incrementer tools–few people know what they’re for. I typically will increment an initial guess at a threshold for an image, for instance.
But I also like to point out that one can get more creative with these buttons. For instance, if one wanted to try out our 6 different (IPT) algorithms for edge detection, the incrementer tools allow that, too:
%%
algs = {’Sobel’,'Prewitt’,'Roberts’,'LOG’,'Zerocross’,'Canny’};
incr = 1; %INCREMENT HERE
imshow(edge(tissueMask,algs{incr}))
title([algs{incr} ‘ Edge Detection’])
Cheers,
Brett
Thanks for that idea, Brett from Pick of the Week. That’s a good use of the incrementer. If my example is the 0-order use, yours is the 1-order. I wonder what the next level is…