Dear all,
Using the next function, I get the error mentioned:
function [Y]=descriptiveStats( X )M={};N=[];M={'mean','sem','numel','std','var','min','max'}.';[mean,sem,numel,std,var,min,max]=grpstats(X,[],{'mean','sem','numel','std','var','min','max'});N=[mean,sem,numel,std,var,min,max].';Y=[M,N];xlswrite('df.xlsx',Y)end
The results displayed in the command window look like this:
>> dFStats = descriptiveStats(decodeFemale);size(M) 7 1size(N) 7 1M 'mean' 'sem' 'numel' 'std' 'var' 'min' 'max'N 1.7802 0.0935 186.0000 1.2749 1.6254 0 4.7137Error using horzcatCAT arguments dimensions are not consistent.Error in descriptiveStats (line 20)Y=[M,N];
However, if I use an additional argument gname that displays a character I don't get the aforementioned error:
function [Y]=descriptiveStats( X )M={};N=[];M={'mean','sem','numel','gname','std','var','min','max'}.';[mean,sem,numel,gname,std,var,min,max]=grpstats(X,[],{'mean','sem','numel','gname','std','var','min','max'});N=[mean,sem,numel,gname,std,var,min,max].';Y=[M,N];xlswrite('df.xlsx',Y)end
And this are the results printed in the command window:
>> dFStats = descriptiveStats(decodeFemale);size(M) 8 1size(N) 8 1M 'mean' 'sem' 'numel' 'gname' 'std' 'var' 'min' 'max'N [1.7802] [0.0935] [ 186] '1' [1.2749] [1.6254] [ 0] [4.7137]
It's not a big deal to have to use the gname argument in order to avoid the error, but I don't understand why it is happening.
Can somebody explain what's the cause and how to fix it?
Regards,
Diego
Best Answer