File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 102102 endif
103103 is_string = true ;
104104 s = cellstr (s );
105- elseif (! (isnumeric (s ) || islogical (s ) || iscellstr (s )))
105+ elseif (isnumeric (s ))
106+ if (! isvector (s ))
107+ error (" grp2idx: 'numeric' grouping variable must be a vector." );
108+ endif
109+ elseif (islogical (s ))
110+ if (! isvector (s ))
111+ error (" grp2idx: 'logical' grouping variable must be a vector." );
112+ endif
113+ elseif (iscellstr (s ))
114+ if (! isvector (s ))
115+ error (" grp2idx: 'cell array' grouping variable must be a vector." );
116+ endif
117+ else
106118 error (" grp2idx: unsupported type for input S." );
107119 endif
108120
419431% !error <grp2idx: 'string' grouping variable must be a vector.> ...
420432% ! grp2idx (string ({'a', 'a'; 'b', 'c'}))
421433% !error <grp2idx: unsupported type for input S.> grp2idx ({1})
434+ % !error <grp2idx: 'numeric' grouping variable must be a vector.> grp2idx ([10, 20; 10, 30])
435+ % !error <grp2idx: 'logical' grouping variable must be a vector.> grp2idx ([true, false; false, true])
436+ % !error <grp2idx: 'cell array' grouping variable must be a vector.> grp2idx ({'a', 'b'; 'c', 'd'})
You can’t perform that action at this time.
0 commit comments