how to set long list of properties and values in matlab -
matlab question:
let's have long list of property names in cell array.
properties = {'property01', 'property02', 'property03', .... , 'property50'};
and corresponding values each property.
values = [val01, val02, val03, ...., val50];
now have function takes variable number of properties input depending upon condition. 1 of main restriction correctly use function call once required properties fed in inputs. (so cannot call function in loop, looping different property setting each time)
e.g. if condition forces me use 4 properties, correct usage be:
output = somefunction(data, 'property01', val01, 'property02', val02, 'property03', val03, 'property04', val04);
how can provide variable number of properties function called once?
mayur narsude
try this:
pv = [properties;values]; output = somefunction(data, pv{:}); basically, create 2xn cell aray, , when gets linearized properties , values alternate.
(that's on calling side. inside function definition, use varargin proposed in answer. guess wasn't clear asking in question.)
Comments
Post a Comment