Mike on the MATLAB Desktop

July 23rd, 2007

Just give me a new line!

Typing several commands to run at the command line can be tedious and hard to read. After typing in several long commands, the text scrolls way over and it is hard to see exactly what has been typed. In the example below, I typed several commands to generate the quiver plot.

shiftenter1.jpg

To make the code easier to read and to make MATLAB wait while you type more commands, hit shift-enter as you enter commands. This adds a new line in the Command Window without executing the code that has already been typed. Another advantage of using shift-enter to type commands in the Command Window is that the commands are added to the Command History as separate commands instead of as one big command.

shiftenter2.jpg

This example is from the 3-D Demo, Quiver section.

6 Responses to “Just give me a new line!”

  1. Steve Eddins replied on :

    Hey, that’s a good one. I didn’t know about that!

  2. Markus replied on :

    If you change the grid in x or y in your example, you will have to repeat all the following commands one by one to get the plot updated. In my opinion it would be better to have all the lines as one big command in the command history.

  3. Kristin replied on :

    Markus – My example may not the best. I am sure there are times when one approach will be better than the other. I’m just trying to show that the option exists.

  4. Ravi replied on :

    This is an off topic question.
    Is it possible to just select a few variables of interest in the workspace browser window and hide the rest? This way, I can monitor and change them without getting distracted by the others.
    It would be nice to be able to at least drag the variables of interest to the top of the window.
    This is perhaps not a “must have” facility. I just felt that it would be convenient to have it.

  5. Kristin replied on :

    Hi Ravi,

    I’ve forwarded your comments to our developer for the Workspace browser to consider for a future release.

  6. Kavinda replied on :

    Thanks a lot! it helped me.

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


MathWorks
Mike works on the MATLAB Desktop team.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.