If you haven't discovered MATLAB shortcuts yet, you really should.
Shortcuts are very useful and could save you a ton of time and effort. For instance, if you find yourself typing the same lines of code everyday why not store them as a shortcut?
Think of the amount of time and effort this will save you in the long run. It really will pay dividends.
We've gathered together a few commonly used ones that, we hope, will make your MATLAB experience a little bit more enjoyable.
This list is clearly not exhaustive and you can create your own very easily.
According to MATLAB "To display tooltips on MATLAB Toolstrip buttons that indicate what keys to press to access those features, press Alt. For example, pressing Alt followed by H accesses the Home tab and displays tooltips for the features available on that tab. You cannot customize these shortcuts.
An action can have multiple keyboard shortcuts. All defined shortcuts work, but only one appears on the desktop Toolstrip tooltip."
Windows: Ctrl + R/Ctrl + T
Mac: ⌘ + / and ⌘ + T
Comments are an essential component of any code. If planned correctly they act as a great aide memoir or guide for the programmer, well anyone really, in the future. It is always good practice to add as many comments as possible for ease of reference when editing or amending the code later on.
To do this in MATLAB simply use the shortcuts above to make adding comments as easy as pie.
Windows: Ctrl + I
Mac: ⌘ + I
Correct indentation is one of the most important features in any programming domain. Most programmers tend to get a little lackadaisical when it comes to indentation. Bad code indentation control can make many projects difficult to control and add unnecessary time, and pressure, to disentangle poorly laid out code.
To do this in MATLAB just use the shortcuts above and make everyone happy.
3. Abort, Abort!!
Windows: Ctrl + C
Mac: ⌘ + C
Aborting is a vital shortcut to learn when testing code. But what if you are running a function and spot a mistake? Especially for large coding projects where letting the code run to completion could take minutes.
To do this in MATLAB is pretty simple using the shortcuts above. Don't sit there like a lemon waiting for the code to run to the end, use Abort and get on with something more productive.
4. Run the code
Windows: F5 for all or F9 for a piece of code
Mac: ⌘ + return or function key and F9 for a piece of code
Hot on the heels of aborting is this great MATLAB shortcut. Running code is an essential method to test what you've written and basically make sure it performs as intended. This is a very important shortcut to learn and use regularly.
And it's a pretty simple MATLAB shortcut. For MAC as the command key (⌘) and return or F5 on other platforms. If you don't want to run the whole code, select a fragment and press F9 instead for PC or function and F9.
5. Switch Panes
Windows: Ctrl + tab
Mac: Ctrl + 1, 2, 3 etc
If you make use of multiple panes in MATLAB's GUI this is definitely a very useful MATLAB shortcut to learn and use. To quickly jump between panes, just use the very easy shortcuts above. Now you can code away to your heart's content in multiple panes and switch between them with ease.
6. Jump to cursor location
Windows: ALT + left arrow key, or right arrow key for the reverse
This one is pretty useful for any MATLAB user, especially if you are editing a lot of functions calls. You will need to set this as a shortcut, however.
With a screen packed with code, it can sometimes be tricky to "find" where the cursor is, especially if you've been immersed in coding. You are only human after all. Using this shortcut will save you a ton of time. Do yourself a favor and learn this shortcut to save you a lot of effort in future.
7. New script
Windows: Ctrl + N
Mac: ⌘ + N
Scripts are one of the simplest kinds of program files simply because they have no input or output arguments. In MATLAB they are incredibly useful for automating commands like computations that are regularly performed from the command line or series of commands.
You can create new scripts very easily from your command history, right-click, and create a script from it. You can also click on the New Script Button or of course define your own shortcut to do this. The choice is yours.
Ah, the escape button. So useful for so many things. In MATLAB this handy little shortcut lets you cancel the current action, whatever that might be. By way of example, if you select the Edit menu, the menu's items are displayed, obviously.
Pressing Esc will retract the menu items, which is handy. If you press Esc in a dialog box it works the same as pressing the Cancel button. Fantastic.
So there you go. 8 handy MATLAB shortcuts for your consideration. Of course, this list is far from exhaustive and in no particular order. Here are 14 more if you are interested. Which shortcuts do you use on a regular basis? Have you created any for yourself? Why not share your favorite shortcuts below.