From: Matt J on

> But it is not always possible to 'vectorize' code (e.g. if operations are inherently sequential). I always make pretty honest efforts to vectorize all code I write, but sometimes it's not possible (and sometimes it's not worth it). This happens often enough that I observe (significant) time penalties if I use a class instance to call a function rather than the handle directly. Besides, many of the codes I write do indeed perform fancy operations by creative uses of lightning-fast precompiled BLAS routines that drive Matlab's array backend; for moderately-sized arrays, the subsref call could double the required time. That's not acceptable to me.
>
> And just as a comment: I'm not actually sure it's subsref that is the time restriction. It could just be that Matlab implementation of classes in general just isn't fast.
===============

Ver y well. But then it's pretty clear that the overhead has nothing to do with MATLAB classes. It's simply because you've written subsref in M-code and all M-code execution is slower in general than C-code, not just class methods. You could have coded subsref as a MEX file, for example, and then it would have been nice and fast...
First  |  Prev  | 
Pages: 1 2 3 4
Prev: imwrite image in an array
Next: CONVERT