Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
object.vector(100) = 1
Posted:
Jan 22, 2013 5:33 PM
|
|
.... does this always re-allocate/copy the complete vector although it is pre-allocated?
classdef SampledSignal properties (GetAccess = 'public', SetAccess = 'public') data; end
methods function this = set.data(this, vector) [...] this.data = vector(:); end end
methods function this = SampledSignal(N) [...] this.data = zeros(N, 1); end end
x = SampledSignal; for n=1:N x.data(n) = func(n); end
takes forever;
x = SampledSignal; data = x.data; for n=1:N data(n) = func(n); end x.data = data;
takes "only" 30 seconds on my old machine. Why? This makes all a little bit meaningless.
Thanks Peter
PS: I know vector operations are faster, this is only unoptimized test-code
|
|
|
|