How to run and analyze a big Matlab class code line by line.
Show older comments
I am new to Matlab classes and I am working on a big Matlab class (600+ lines in total) where I need to check outcome from each executable line in terms of variables being used and returned and their size, type etc. so that I can remove unnecessary variables and preallocate all necessary variables. I tried putting break points but it seems that Matlab goes upto end of methods and not beyond that where actual work starts. I am aware of mlint, tic-toc and profiler for optimizing Matlab codes but for that I need to run the whole thing first. Can anyone please let me know if it is posssible at all to run a Matlab class with breakpoints?
2 Comments
Geoff Hayes
on 24 May 2014
Yes, it is possible to put breakpoints in a class definition and have the code break in the appropriate place. I often do this.
Note that if you ever change the code, then you must run clear all to refresh the class definition. Maybe that is why you are having problems - changes are being made to the class definition, a new instance of that class is created using the old definition and stepping through the code is confusing.
Note that e.g.
clear all
clears all break points. Therefore, if you have a script in which you create an object based on a classdef which contains break points, if the script starts will clear all, your break points are gone. So keep in mind that you may have to comment out a few calls to clear before you run the script.
Accepted Answer
More Answers (0)
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!