The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Code folding
Replies: 16   Last Post: Aug 12, 2014 9:33 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
John D'Errico

Posts: 9,130
Registered: 12/7/04
Re: Code folding
Posted: Aug 12, 2014 9:33 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Jason " <> wrote in message <lscfm6$3h9$>...
> "Sarah Hunt" <> wrote in message <ic67u0$92g$>...
> > "Juliette Salexa" <> wrote in message <h08svt$c4g$>...
> > > Thank you Steve,
> > > but I don't have a clue what you mean by that. I said I haven't been using functions at all, which (I think) means all my code is 'script' already.. Please correct me if I'm wrong.
> > >
> > > "Steve Amphlett" <> wrote in message > You could make it a script (not function).

> >
> > Hi Juliette, Did you ever manage to find out how to fold your script?

> Hey, an easy shortcut to folding your cold is to put whatever block you'd like to fold in a simple for loop
> For i=1
> %code code code; watch out for the usage of your loop variable i
> end
> Then, assuming that you have a new enough version of Matlab, you can click + or - next to the for loop to hide the entire loop.

You CAN do this, but it is not something I'd advise. It makes
your code more difficult to read. Why did I put that loop there?
What does that end statement correspond to? It creates a
spurious variable, here i. Worse, the variable i is already defined
in MATLAB. So you may have just created an inadvertant bug.

Adding an extra for loop is silly, when you can do the same
thing by putting %% comments before and after the block you
might wish to fold. Then enable code folding for sections in the
preferences pane for the editor.

NEVER make your code less readable.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.