How to get multiple outputs of a function in a vector?
问题 Say I have a function whose outputs are two reals a and b [a,b]=function(c) I'd like to get all the outputs in a vector v. v=function(c) doesn't do what I want, v is 'a' only. Of course here I could do v=[a,b]. But the function in question is ind2sub for a N-D array so it gives n outputs that I'd like to have in a vector directly. Is there a way to do it? Thanks very much! 回答1: You can use a cell array and a comma-separated list like so: X = cell(N, 1); [X{:}] = function(C); The syntax X{:}