Date: Jan 22, 2013 5:33 PM
Author: Peter Mairhofer
Subject: object.vector(100) = 1

.... 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