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
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.
I’m pretty sure breakpoints in cell-mode are on the radar of The Mathworks… just not implemented yet.
See this discussion for example:
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.
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.
Also have a look at Loren’s excellent blog here: