Stuart’s MATLAB Videos

Watch and Learn

Managing code in MATLAB: Cell mode scripts 5

Posted by Doug Hull,

This is the first series of MATLAB video tutorials that are an attempt to systematically make videos for a “technology trees” for using MATLAB. This first tree covers the various kinds of MATLAB files you might write. The tree shows you the order you should watch them because some rely on skills you need to learn from earlier videos, but some do not.

Script Function 1in1out MinNout VarArg Cell mode Markup Interactive Driver script Sub function Nested

Cell mode scripts are a way to make something like a “MATLAB workbook”. They can be used to make easily published documents (upcoming video), allows you to break your scripts into smaller chunks that can be run individually, and allow you to iterate on a section of code while changing a scalar (upcoming video again!). This last method allows you to tune a constant very easily.

5 CommentsOldest to Newest

Kelly replied on : 1 of 5

I always feel the need to add my 2 cents when cell mode is mentioned. I love it, and use it often in my model analysis code. However, there are two things that really drive me crazy about it:

1) debugging is very limited. While I can issue catch-alls like “dbstop if error”, I can’t add a breakpoint to cell mode code… or rather, I can add one, but it has no effect if the code is run cell by cell.

2) Errors messages are thrown without line numbers. Really aggravating when you make a stupid mistake and can’t track down where the error is coming from, particularly since you also can’t debug.

Seems like these bugs have existed for many, many releases… any chance they might be fixed in a future release?

Glad they finally fixed the silent-syntax-error issue though.

Paulo Silva replied on : 3 of 5

Good tutorial, reminds me of a time when I was testing someone else code and it was full of cells (first time I had code with cells), just doing the Evaluate Cell like crazy expecting all the code to run, good memories.

William Knox replied on : 4 of 5

Try adding a pause statement, where you would normally add a breakpoint. You could also add the relevant test code and if the test fails then pause or do what is needed to get/view the desired information; remove the test code on release version i.e. if in debug mode run test/compile code, if not, don’t.

Add A Comment

Your email address will not be published. Required fields are marked *

What is 3 + 9 ?

Preview: hide