MATLAB: Do I receive a “Too many output arguments” error when I use EVAL with DEAL of a struct with greater than 20 elements in MATLAB Version 6.5.0 (R13) or higher

MATLAB

When I execute the commands
cd D:\Applications\Matlab71\toolbox\matlab\matfun
Directory = dir('*.m');
num = 22;
[CellArray{1:num}] = eval( 'deal(Directory(1:num).name)' );
I receive the following message if "num" is greater than 20:
??? Error using ==> eval
Too many output arguments.

Best Answer

This is expected behavior of the EVAL command. This issue is due to the EVAL function's limit of 20 or more output arguments.
To work around this issue, rather than using the EVAL command as follows:
[CellArray{1:num}] = eval('deal(Directory(1:num).name)');
use the commands:
[ CellArray{1:num} ] = deal( Directory(1:num).name );
If you require the use of the EVAL command, try the commands:
eval([ CellArray{1:num} ] = deal( Directory(1:num).name ) )