Ken & Mike on the MATLAB Desktop

November 26th, 2007

Giving your code some privacy

In R2007b, code folding was introduced in the Editor for functions and help comments. I find this particularly useful for large M-files like edit.m, which have a lot of subfunctions. By collapsing all the folds in the file, I can quickly skim through the helper subfunctions.

foldededit.PNG

The Editor remembers which folds I had collapsed in each file, even between sessions of MATLAB, and I can choose to disable code folding if I wish from the preference panel:

codefoldingprefs.PNG

At this point, I know what all of you are saying– “Why does this only work for functions? I want to be able to fold all my MATLAB keywords!”. Don’t worry, I’ve already heard you, and that will be in a future release. In the meantime, try out our first version of code folding and let us know what you think!

4 Responses to “Giving your code some privacy”

  1. J.R.Menzinger replied on :

    That’s great!
    but… I’m waiting since 4 or 5 Releases for these option:
    SAVE BREAKPOINTS
    SAVE BREAKPOINTS CONDITIONS
    SAVE BOOKMARKS
    by leave the session.

    I think it should be easy to implement, isn’t it?

    Best Regards

    J.R.!

  2. Ken replied on :

    Hi J.R.,

    Your absolutely right! Saving breakpoints, breakpoint conditions and bookmarks are blatantly missing features.

    You can actaully save breakpoints and conditional breakpoints manually by doing the following:

    To save:

    >> mybreakpoints = dbstatus;
    >> save mydebugsession mybreakpoints

    To load:

    >> load mydebugsession mybreakpoints
    >> dbstop(mybreakpoints)

    We are currently working on more seamless ways to do this though.

    -Ken

  3. Will Dampier replied on :

    Personally, I love the new folding feature. I would love to see folding SWITCH statements since I often parse through dozens of input arguments to VARARGIN and they often take up 100 or more lines of particularly ugly code (try-catches, warnings messages, error messages, long conditional statements). I’ve started to put them into a large subfunction which modifies pre-initialized flag variables just so I can foldd it out-of-site but I don’t like habitually sharing variables between functions like that.

    Thanks
    Will

  4. Christina Roberts replied on :

    Hi Will,

    We will fold switch statements in a future release. Thanks for letting us know how you are using code folding!

    -Christina

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).


Ken & Mike work on the MATLAB Desktop team.
  • DP: Hi i have a problem with ezplot3, i want to plot more than i curve in the same graph but hold on command...
  • Ken: Hi Arsalan, Unfortunately there is no way to get the new Editor API in older versions of MATLAB. -Ken
  • Arsalan: Hi, I am very excited about the MATLAB API for editor because right now i am working on a project and i need...
  • Johannes: Since I started using matlab-emacs some days ago I never experienced Emacslink. But I experienced some...
  • Francisco J. Beron-Vera: Hi all, I have recently learned about ViEmu (http://www.vimemu.c om) which, for Vi/Vim...
  • OysterEngineer: When I first learned of the Publish feature in MatLab, I thought it might be useful to help to...
  • Ken: Hi Herve, I’m not quite sure what you mean by “stand-alone&# 8221; mode? -Ken
  • Herve: I wonder when the publish fonction will be supported in standalone mode.
  • Mike: Ravi, What you described should work as far I understand it. Please follow up with technical support. With a...
  • Mike: @Daniel, Thanks for that note.

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