You can also create a class so that the call is SetPropertyvectorized:
class Foo < handle
methods(Access=public)
function SetProperty(this,val)
assert(numel(this)==numel(val));
for i=1:numel(this)
this(i).prop = val(i);
end
end
end
end
Then you can create a vector and immediately call the method:
f = repmat(Foo(),[1 2]);
f.SetProperty( [5 3]);
source
share