8 Handy MATLAB Shortcuts That Will Save You a Ton of Time

Shortcuts are a great way to quickly and efficiently perform functions you use on a regular basis. Here are 8 MATLAB shortcuts you might want to learn.

8 Handy MATLAB Shortcuts That Will Save You a Ton of Time

MeccanismoComplesso/MatLabTips

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 every day, 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 not exhaustive, and you can easily create your own

MATLAB tries to follow the “muscle memory expectation” of each platform, so MATLAB shortcuts are OS-dependent.

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 available features. 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.” 

1. Comment/Uncomment

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.

To do this in MATLAB, simply use the shortcuts above to make adding comments as easy as pie.

2. Auto-Indent

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. 

Source: MathWorks

3. Abort, Abort!!

Windows: Ctrl + C

Mac: ⌘ + C

Aborting is a vital shortcut you should know 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. 

Source: MemeGenerator

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.

Source: MathWorks

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 easily code away to your heart’s content in multiple panes and switch between them.

6. Jump to the 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 function 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 the future. 

Source: Nevit Dilmen/Wikimedia Commons

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 easily create new scripts 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.

Source:Engineer101

8. Escape!

Windows: Esc

Mac: Esc

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.

Source: Atlasowa/Wikimedia Commons

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 regularly? Have you created any for yourself? Why not share your favorite shortcuts below?

RECOMMENDED ARTICLES

Via: MathWorks, KeyXL 

0COMMENT
NEWSLETTER
The Blueprint Daily

Stay up-to-date on engineering, tech, space, and science news with The Blueprint.

By clicking sign up, you confirm that you accept this site's Terms of Use and Privacy Policy

ABOUT THE EDITOR

Christopher McFadden Christopher graduated from Cardiff University in 2004 with a Masters Degree in Geology. Since then, he has worked exclusively within the Built Environment, Occupational Health and Safety and Environmental Consultancy industries. He is a qualified and accredited Energy Consultant, Green Deal Assessor and Practitioner member of IEMA. Chris’s main interests range from Science and Engineering, Military and Ancient History to Politics and Philosophy.