J'ai trouvé un moyen de le faire. Grâce à la réponse de Will Robertson, j'ai réalisé que l'écriture d'une fonction était la seule façon d'obtenir ce que je voulais. Voici divisé.
function [ o1, o2, o3, o4, o5, o6, o7, o8 ] = split(v)
%SPLIT Splits a vector of bounded length into individual return variables.
% Split() can handle arbitrarily long input vectors, but only a fixed
% number of output variables. @benathon
%
% Usage:
% vec = [1 2 3 4 5];
% [a,b,c,d,e] = split(vec);
% [f,g] = split(vec);
% If you would like to upgrade split() to handle more output variables,
% simply add more output variables to the function definition and
% then change this variable
maxout = 8;
[~,n] = size(v);
if n < nargout
error('input vector too short for number of output arguments');
end
% we only need to assign this many output variables
iterations = min(n,nargout);
% Matlab catches "Too many output arguments." before we can
%if(iterations > maxout)
% error('Too many output, edit split.m to easily upgrade');
%end
i = 1;
while i <= iterations
expression = sprintf('o%d=v(%d);', i, i);
eval(expression);
i = i + 1;
end
Regardez dans les commentaires pour l'utilisation. J'ai également fait un résumé: https://gist.github.com/esromneb/652fed46ae328b17e104
Jetez un oeil à [ 'varargout'] (http://www.mathworks.com/ help/matlab/ref/varargout.html? refresh = true) et également à ['nargout'] (https://nf.nci.org.au/facilities/software/Matlab/techdoc/ref/nargin.html) – Dan
'size()' est une fonction. Donc quand vous faites 'size ([0 0])', il va dans la fonction interne et retourne deux arguments. Dans le second cas, 'sz' est une variable qui est un vecteur de longueur 2. Maintenant, vous essayez d'assigner une seule variable à deux variables. Cela n'arrivera pas. Vous pouvez écrire votre propre fonction pour le faire. –
regardez ici pour plusieurs affectations variables: http://stackoverflow.com/questions/2740704/is-there-anythinglike-deal-for-normal-matlab-arrays – zinjaai