Passing parameters to a Matlab function -
i have simple question, didn't figure out how solve this.i have function definition below:
function model = oasis(data, class_labels, parms) % model = oasis(data, class_labels, parms) % % code version 1.3 may 2011 fixed random seed setting % code version 1.2 may 2011 added call oasis_m.m % code version 1.1 may 2011 handle gaps in class_labels % % input: % -- data - nxd sparse matrix (each instance being row) % -- class_labels - label of each data point (nx1 integer vector) % -- parms (do sym, do_psd, aggress etc.) % % output: % -- model.w - dxd matrix % -- model.loss_steps - binary vector: there update @ % each iterations % -- modeo.parms, actual parameters used in run (inc. defaults) % % parameters: % -- aggress: cutoff point on size of correction % (default 0.1) % -- rseed: random seed data point selection % (default 1) % -- do_sym: whether symmetrize matrix every k steps % (default 0) % -- do_psd: whether psd matrix every k steps, including % symmetrizing them (defalut 0) % -- do_save: whether save intermediate matrices. note % saving before symmetrizing and/or psd in case exist % (default 0) % -- save_path: in case do_save==1 filename needed, % format save_path/part_k.mat % -- num_steps - number of total steps algorithm % run (default 1m steps) % -- save_every: number of steps between each save point % (default num_steps/10) % -- sym_every: integer multiple of "save_every", % indicates frequency of symmetrizing in case do_sym=1. % end step symmetrized. (default 1) % -- psd_every: integer multiple of "save_every", % indicates frequency of projecting on psd cone in case % do_psd=1. end step psd. (default 1) % -- use_matlab: use oasis_m.m instead of oasis_c.c % provided in case of compilation problems. %
i want use function, don't figure how set parameters, or use default values. variable parms in case, object keep other variables? can make python syntax put name of parameter plus value? example:
model = oasis(data_example, labels_example, agress = 0.2)
additionally, if have understood correctly, 2 objects in output, model , modeo, need make call receive contents function returns?
[model,modeo] = oasis(data_example, labels_example, ?(parms)?)
from documentation above, don't know 1 right, there 2 common ways optional parameters in matlab.
parameter value pairs:
model = oasis(data, class_labels, 'do_sym',1,'do_psd',0)
structs:
params.do_sym=1 params.do_psd=0 model = oasis(data, class_labels, params)
probably 1 of these 2 possibilities right.
Comments
Post a Comment