chooseargs
C = chooseargs(f,argidx,idxc,[f_inputs])
chooseargs allows direct selection of any
combination of arguments to a function f
that has the following form:
[y1,y2,...,yM] = f(f_inputs)
and outputs a cell C such that:
C{k} == y[argidx(k)](idxc{k}).
Comma-separated multidimensional
indices are allowed if the entries of
the cell idxc are themselves cells.
Example:
A=magic(3)
[y1,y2]=max(A);
%returns y1=[8,9,7], y2=[1,3,2]
chooseargs(@max,1,[2,3],A)
%returns y1([2,3])=[9,7]
chooseargs(@max,1,{1,[2,3]},A)
%returns y1(1,[2,3])=[9,7]
chooseargs(@max,2,[],A)
%returns y2=[1,3,2]
chooseargs(@max,2,{[1,1],[2,3]},A)
%returns y2([1,1],[2,3]) = [3,2;3,2]
chooseargs(@max,[1,2],{{[1,1],[2,3]},[]},A)
%returns {y1([1,1],[2,3]),y2}
% = {[9,7;9,7],[1,3,2]}
Cita come
Adam Gripton (2025). chooseargs (https://it.mathworks.com/matlabcentral/fileexchange/35115-chooseargs), MATLAB Central File Exchange. Recuperato .
Compatibilità della release di MATLAB
Compatibilità della piattaforma
Windows macOS LinuxCategorie
- MATLAB > Programming > Functions > Function Creation >
Tag
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.
| Versione | Pubblicato | Note della release | |
|---|---|---|---|
| 1.0.0.0 |
