How to get all outputs of a function in a cell array
Show older comments
I created a function that has a different number of outputs depending on the inputs. I store the outputs into a cell, varargout. When I call the function to try and get the output, I only get the first element of the cell.
function varargout = testfunc(a,b)
varargout = cell(1,a);
for i = 1:a
varargout{i} = b;
end
end
t = testfunc(3,2)
t =
2
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!