time | Calls | line |
---|
| | 1 | function t = strcat(varargin)
|
| | 2 | %STRCAT String horizontal concatenation.
|
| | 3 | % T = STRCAT(S1,S2,...), when any of the inputs is a cell array of
|
| | 4 | % character vectors, returns a cell array of character vectors formed by
|
| | 5 | % concatenating corresponding elements of S1,S2, etc. The inputs must
|
| | 6 | % all have the same size (or any can be a scalar).
|
| | 7 |
|
| | 8 | % Copyright 1984-2016 The MathWorks, Inc.
|
| | 9 |
|
< 0.001 | 102 | 10 | narginchk(1, inf);
|
| | 11 |
|
| | 12 | % Make sure everything is a cell array
|
< 0.001 | 102 | 13 | maxsiz = -1;
|
< 0.001 | 102 | 14 | siz = cell(1, nargin);
|
< 0.001 | 102 | 15 | for i = 1:nargin
|
< 0.001 | 206 | 16 | if ischar(varargin{i})
|
0.003 | 104 | 17 | varargin{i} = cellstr(varargin{i});
|
< 0.001 | 102 | 18 | elseif ~iscell(varargin{i})
|
| | 19 | if isempty(varargin{i})
|
| | 20 | varargin{i} = {''};
|
| | 21 | else
|
| | 22 | error(message('MATLAB:strcat:InvalidInputType'));
|
| | 23 | end
|
< 0.001 | 206 | 24 | end
|
< 0.001 | 206 | 25 | siz{i} = size(varargin{i});
|
< 0.001 | 206 | 26 | if ~isscalar(varargin{i}) && prod(siz{i}) > prod(maxsiz)
|
| | 27 | maxsiz = siz{i};
|
< 0.001 | 206 | 28 | end
|
< 0.001 | 206 | 29 | end
|
| | 30 |
|
< 0.001 | 102 | 31 | if isequal(maxsiz, -1)
|
< 0.001 | 102 | 32 | maxsiz = [1, 1];
|
< 0.001 | 102 | 33 | end
|
| | 34 |
|
| | 35 | % Scalar coercion
|
< 0.001 | 102 | 36 | for i = 1:length(varargin)
|
< 0.001 | 206 | 37 | if prod(siz{i}) == 1
|
0.002 | 206 | 38 | varargin{i} = varargin{i}(ones(maxsiz));
|
< 0.001 | 206 | 39 | siz{i} = size(varargin{i});
|
< 0.001 | 206 | 40 | end
|
< 0.001 | 206 | 41 | end
|
| | 42 |
|
0.001 | 102 | 43 | if (numel(siz) > 1) && ~isequal(siz{:})
|
| | 44 | error(message('MATLAB:strcat:InvalidInputSize'));
|
< 0.001 | 102 | 45 | end
|
| | 46 |
|
< 0.001 | 102 | 47 | s = cell([length(varargin) maxsiz]);
|
< 0.001 | 102 | 48 | for i = 1:length(varargin)
|
0.002 | 206 | 49 | s(i, :) = varargin{i}(:);
|
< 0.001 | 206 | 50 | end
|
| | 51 |
|
< 0.001 | 102 | 52 | t = cell(maxsiz);
|
< 0.001 | 102 | 53 | for i = 1:prod(maxsiz)
|
0.001 | 102 | 54 | t{i} = [s{:, i}];
|
< 0.001 | 102 | 55 | end
|
Other subfunctions in this file are not included in this listing.