1

I've been asked to recode a MATLAB simulation of a matching algorithm. Here's the basic idea:

d = data;
for s = 1:S
   add randomness to data
   run matching algorithm on data
   store result
end  

It was suggested to me that recoding using objects will speed up the code. Will, for example, recoding data as an instance speed up the code? The idea was that rather than passing this big data matrix back and forth between functions, if only a pointer is passed back and forth, this will be faster. Is this true in general? Might it be true?

Thank you!

htedr
  • 11
  • 2
  • Pass-by-address is always faster than pass-by-value. – Budo Zindovic Dec 06 '15 at 23:05
  • 5
    Matlab uses [copy-on-write](http://blogs.mathworks.com/loren/2006/05/10/memory-management-for-functions-and-variables/) so there is no real penalty for passing big arrays into normal functions in many cases. OOP programs can use either [pass by reference or pass by value](http://mathworks.com/matlabcentral/answers/152#answer_150), but generally [OOP is slower in Matlab](http://stackoverflow.com/a/1745686/2278029) even if it's performance has increased lately. However, the largest effect may be due to programmer skill in many cases –if your current code is slow you should try to understand why. – horchler Dec 06 '15 at 23:17
  • thanks for the responses, and horchler thanks especially for the links. – htedr Dec 07 '15 at 01:40

0 Answers0