Tuesday, November 29, 2005

matlab tips

[-] use length(x) instead of max(size(x)) in most of my case.
[-] eval?
================

[-] Remove the ticks from a drawing.
set(gca, 'XTick', []);
set(gca, 'YTick', []);

================

[-] Matlab automatically resizes the matrix. To avoid frequent reallocations, preallocate the matrix with the zeros command.

a = zeros(1,8000).
If the final array size can vary? cut the excess after the loop.

a = zeros(1, 10000);
count = 0;
for ...

a = a(1:count); % trim the result
===============

If you have complex code that's resource hungry, find the bottlenecks by profiling your code:

profile on

run your script here
profile off
profile report


===============
mlint - Helps determine problems in your code.

No comments:

Post a Comment