Reputation: 403
I wondered if it could be that a function of the type
[output1,output2,...] = function(arg1,arg2,...);
thus with multiple outputs (in this case output1
, output2
,... are vectors but could be everything else) could be called by assigning it to a structure without having to write
[Structure.output1,Structure.output2,...] = function(arg1,arg2,...);
In other words, how (if it's possible and I doubt it) something approaching this could work?
structure.[output1,output2,...] = function(arg1,arg2,...);
The reason why I ask this is because I have a looot of outputs... But I admit this is some laziness :p
Upvotes: 0
Views: 331
Reputation: 9864
It is possible, but not in a one-liner that you are looking for. Say you have N
outputs then you can use
c = cells(N,1);
[c{:}] = function(arg1,arg2,...);
structure = cell2struct(c, {'output1' 'output2' ...}, 1);
Upvotes: 3