File: ef230-2023-08/www/examples/cell_extract.m Download
function main

% test cases / examples
answers = {'1','2','42'};
[uno dos life] = cell_extract(answers)
nums = [18;5;30];
[a z w] = cell_extract(nums)
[a z w junk] = cell_extract([1 2;3 4])
[a z w junk] = cell_extract([1 2 3])


function [varargout] = cell_extract(matrix)
% simple function to extract values from a matrix
if nargout > prod(size(matrix))
    error('# outputs > # inputs');
end
for i=1:nargout
    if iscell(matrix)
        varargout{i}=matrix{i};
    else
        varargout{i}=matrix(i);
    end
end
return