If you haven’t discovered Shortcuts yet, you should. Shortcuts are useful for storing small snippets of m-code that you regularly run. If you find yourself typing the same 3 or 4 lines of code everyday, you should select those lines in the Command History (or the Command Window) and drag them up to the Shortcuts Toolbar in the Desktop. This will automatically create a shortcut on the toolbar.
A dialog will open where you can modify the code, give it a catchy name, and even change the icon.
The shortcut shows on the Shortcuts Toolbar.
Shortcuts also show in the MATLAB Start Button. In the Shortcuts menu in the Start Button, you will find all of your Shortcuts including the Toolbar Shortcuts and any Help browser favorites you may have bookmarked. In this area, you can create more categories of shortcuts for even greater storage capacity and organization.
When your shortcuts start getting a little disorganized, you can open the Shortcuts Organizer from the Shortcuts Toolbar context menu or the Start Button Shortcuts menu. In this dialog, you can move items up and down and into categories, rename items, create new categories, and delete items.
So, if you haven’t already, give Shortcuts a try. It is as easy as drag and drop.
Do you have a favorite Shortcut? We’d love to hear what it is.
30 CommentsOldest to Newest
1) Is there a way to modify the layout so the shortcuts will be accessible in the lower part of the screen ? (if getting there thru “Start”, have to cascade thru two menus)
2) I have three favorite shortcuts:
Delete All Children
delete(allchild(0)) % stronger than close all
% get state
% reset state
Toggle Stop On Error
dbstop if error
fprintf(‘Stop on Error ON\n’);
dbstop if error
fprintf(‘Stop on Error ON\n’);
dbclear if error
fprintf(‘Stop on Error OFF\n’);
There is not currently a way to move the start button to another location. We are looking into other ways we can display this information and also considering allowing users to add folders to the shortcuts toolbar which would allow you to store more information on the toolbar and have it be categorized.
I like the toggle stop on error. I am sure this will be useful to others.
Great article, Kristen. Since I work with a lot of time series data, I’ve become a huge fan of linkaxes to link zooming across multiple axes. This lets me see what’s happening at a particular time for data spread across multiple plots. This leads to my favorite shortcut:
Title: X Link Zoom
linkaxes(findobj(0,’Type’,'Axes’,'-not’,'Tag’,'legend’),’x'); zoom on
Icon: \toolbox\matlab\icons\view_zoom_in.gif (close enough)
What about the possibility to have faster access to the shortcuts directly from the editor window.
Creating graphs directly from the editor I use shortcuts to toggle grid, hold, etc and would welcome this possibility.
I like these shortcuts. I’ve been trying to create a set of shortcuts on start up, but the method described in the documentation does not work (adding ‘/r filname’ after the target in the matlab shortcut. This is described in the “Startup Options in Windows Shortcut” section of the documentation).
Is there a way to automatically execute certain commands when matlab is launched?
The documentation refers to creating Windows application shortcuts. These are different. In a windows application shortcut, you can add “-r function_name” after matlab.exe to get MATLAB to run code after it initializes on startup. You can also create a startup.m file and place it in your startup directory to achieve the same effect. You should be able to find more info on startup.m in the doc too.
Does that help?
Hi Michel, Do you mean that you would like a shortcuts toolbar in the Editor? I’ll put in an enhancement request for that.
Thanks, I will certainly appreciate it a lot.
As 95% of my work is done from the editor window, I do not like to interrupt the going stream of work by switching to the command window.
It can be very useful if I could put a function on the shortcuts bar. I am thinking on selecting a variable or a set of variables from the Workspace or even the command window press the shortcut and run the desired function.
Thanks for the feedback Amir.
When I add/remove/modify shortcuts in the Toolbar, they seem to be reflected in the shortcuts.xml file immediately.
Is there a way to update the shortcuts in the Toolbar, when I modify the shortcuts.xml file?
My goal is to update the Shortcuts Toolbar using scripts. Please let me know if you have any suggestions.
I found the following response in the newsgroup:
>>> Michael wrote:
>>> Is it possible to set and delete shortcuts by command line?
>>It is not currently possible. I do have an enhancement request to
>>provide an M command to do this and I will consider it for a future release.
I would like to know if this feature is available now and if so, for which Matlab release?
Thanks in advance,
This is still not available. And we are still considering it for a future release. Thanks for letting us know you are interested in this feature.
This is my favorite shortcut, a Windows Explorer shortcut for the current directory. It’s on the Matlab file exchange at:
That’s a good one Stead: winopen(pwd). What tools is the Current Directory browser missing for you that make you want to open Windows Explorer? Is this something we could fix?
One of the main reasons I need to open Windows Explorer is to use TortoiseSVN for source/revision control. TortoiseSVN ( http://tortoisesvn.net/ ) is a Subversion client that is implemented as a Windows shell extension that integrates into the Windows Explorer. On the surface, the Matlab Current Directory browser looks a lot like the Explorer and it would be handy to be able to access the TortoiseSVN contextual menu from there, but that may not be practical.
Also, its a lot faster to navigate (and look for files) with Windows Explorer, especially since the Current Directory browser doesn’t have an integrated folder (tree) view.
Thanks for asking!
Where is the shortcut’s info stored?
Is it possible to pass all the shortcuts to another user?
Javier – if you type “prefdir” at the MATLAB command line you will see the directory where they are stored. In that directory, there is a file called shortcuts.xml. If you make changes to the file manually, you will want to do it while MATLAB is closed.
There is not currently a way to import in another users shortcuts. I do have an enhancement request to provide that functionality in the future.
Is there a way to add shortcuts to Simulink (in the menu of a model)?
Or is there a way to modify the the menu(File Edit Debug Desktop…) to add your own menu items for Simulink (and/or Matlab)?
You can add items to the Simulink menus by adding a sl_customization.m file to your MATLAB path. Details can be found by starting here: http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/index.html?/access/helpdesk/help/toolbox/simulink/ug/bqt2_v7-1.html&http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/helptoc.html.
This is a bit out of our area, so for further advice you should contact technical support (see link at the right), post to comp.soft-sys.matlab or bug Seth to create a post on his blog about that.
As for the main MATLAB menu, we do not currently support that functionality, but we will take it under consideration.
Thanks for the great question.
is there a way to use shortcuts to insert some text at the cursor position in the Matlab Editor (on Windows)?
I thought of an ActiveX or Java solution, but I appreciate any hints.
There is not currently a way to insert text into the MATLAB Editor programatically. I’ll create an enhancement request for this.
This is my “cleanup” shortcut
clc % clear Command Window
close all hidden % deletes all figures including those with hidden handles.
bdclose all % closes all system windows
imtool close all % closes all image tools
com.mathworks.mlservices.MLEditorServices.closeAll; % close MATLAB editor
com.mathworks.mde.desk.MLDesktop.getInstance.closeHelpBrowser % close the doc page
com.mathworks.mlservices.MatlabDesktopServices.getDesktop.closeGroup(‘Web Browser’) % to close an URL open with the WEB function
com.mathworks.mlservices.MLCommandHistoryServices.removeAll; % to clear the history
clear all % remove items from workspace, freeing up system memory
Hi guys, I like the shortcuts and use them regularly. Sometimes, however, I have to use a public computer at school. These are “deep-frozen” and are set to a default setting at every log on. I’d like to use my shortcuts on these computers. I figure that I could write a script – for execution when I start my day at school – which creates shortcuts to my code on my external HD.
If I’m clever, I’ll figure out a way to MATLAB execute this in a startup.m script, but more likely I’ll just have to locate the script and run it in MATLAB.
Anyway, my problem is: I can’t figure out how to create these shortcuts via a script. Is there any way to do this via the command window? Thanks in advance for your help and advice,
Sorry to bother you guys with that request. I now see that you did in fact already answer it above in the thread…
I want to second Amir’s request from reply No.9. Is any functionality like that planned for the future?
A related feature that would be interesting for me would be some way to customize the context menu items when right-clicking on a variable in the workspace editor.
It is something we are considering. You may also be interested in the new R2009b plot picker, which we will feature in a future post.
Can I have a key or a combination of keys assigned to user defined shortcuts?
I agree with Stead, being able to use SVN from the matlab file explorer would be great!
Also, I run into a problem on my mac where if I copy a file(cmd+c) while in the matlab file explorer, change directories, and paste it (cmd+v) still in the matlab file explorer, then when I use that file the permissions are all messed up, it is like matlab is operating as another use with non-administrator permissions. I particularly find this to be a problem when I move executable files. I have not noticed an issue with other file types.
I guess a second feature creep while I am posting; A feature that I really like in matlab is the auto suggest textbox that comes up for functions, idk what it is really called, but for example if I type in “str2num(” then a box comes up showing “str2num(‘str’)” I would really love a way to enable this for my functions as well. Currently they all just come up with a box showing “myfcn(…)” Is there a way to add this functionality to my .m files?
-I realize most of this is not in the correct thread but I read others posts and it made me think of it. Also, I have started using these shortcuts and wow its a great time saver! Great feature!
I will forward your issue on to the development team for the file explorer. What you’re asking for in the second paragraph is a support for user functions in Function Hints. It’s something we’re actively working on, but not part of the product yet.