View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

5.0 | 1 rating Rate this file 10 Downloads (last 30 days) File Size: 214 KB File ID: #28929 Version: 1.1
image thumbnail




03 Oct 2010 (Updated )

tracer4m traces calls to methods and functions.

| Watch this File

File Information

tracer4m traces calls to methods and functions.
Object-oriented design is about distributing responsibilities among interacting objects.
The objects should be small and focused. This results in a complex flow of calls.
Furthermore, in a GUI the user manipulates controls, which in turns trigger events and
chains of calls to methods and functions. There is a need to trace the calls.
The goal of tracer4m is to support unit testing, debugging, and analysis of existing code.
Example based on "Example - Using Events to Update Graphs" from the Matlab on-line help
feobject = fcneval( @(x,y) x.*exp(-x.^2-y.^2), [-2 2 ] );
fcnview.createViews( feobject );
log = TraceHistory.Instance;
log.setup( { 'fcneval', 'fcnview', 'createViews' } )
feobject.FofXY = @(x,y) x.*exp(-x.^.5-y.^.5);
disp( log )
feobject.Lm = [-8 3];
disp( log )

Part of the result is depicted in the image above.

Documentation: tracer4m_demo.html, which is generated by PUBLISH, discusses and demonstrate the use and behaviour of tracer4m.

I would appreciate comments especially regarding requirements on tracing tools for Matlab

Required Products MATLAB
MATLAB release MATLAB 9.0 (R2016a)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
14 Sep 2016 Therry

Therry (view profile)

Hello Per,
the new issue works well! Thank you for the good tool.
Best Regards

Comment only
17 Aug 2016 Therry

Therry (view profile)

Hello Per,
using tracer4m in Release R2016a with the tracer4m_demo runs in a problem in TraceHistory line 188ff {for ii = 1 : numel( sam )} for line 202 (s2 = regexp( sam(ii+1).message). In the last loop sam(ii+1) doesn't exist. Can you help?
Best Regards

Comment only
01 Nov 2012 per isakson

Jesse, thanks for the comment. The purpose of pause(0.001) *was* to ensure that each successive call should have a unique timestamp. That was useful during debugging.

Comment only
23 Oct 2012 Jesse Hopkins

Jesse Hopkins (view profile)

Wow thank you for this incredibly useful utility. I had one hickup which was user error. I used the output of "dir" to pass into the setup function, which broke the setup. Worked fine once I stripped off the ".m" extension from the filenames returned by dir.

Afterwords, everything "just worked", and I was able to get incredibly useful traces. I had attempted something simliar in the past, but never could get anything working without instrumenting the code. Well done using mlint & conditional breakpoint side effects to get function traces without needing to modify code.

Question: Why call pause(0.001) in TraceHistory.add?

11 Sep 2016 1.1

Fixed the problem with R2016a reported by Therry. The revised code is tested only on R2016a, but "should" run on older versions.

Removed the limitation regarding function name reported by Jesse Hopkins. Now it also takes file names with wildcards.

11 Sep 2016 1.1

Previous upload failed. Better luck this time :-)

Contact us