comparison scripts/strings/strtrunc.m @ 13304:e1524d82f8e0

strtrunc.m: Fix errors in strread, textscan introduced by changeset 86d18a3cc911 * strtrunc.m: Fix errors in strread, textscan introduced by changeset 86d18a3cc911
author Rik <octave@nomad.inbox5.com>
date Sat, 08 Oct 2011 20:14:35 -0700
parents b68b354a39c2
children ad9b78544a22
comparison
equal deleted inserted replaced
13303:db15303ee267 13304:e1524d82f8e0
36 endif 36 endif
37 elseif (iscellstr (s)) 37 elseif (iscellstr (s))
38 ## Convoluted approach converts cellstr to char matrix, trims the character 38 ## Convoluted approach converts cellstr to char matrix, trims the character
39 ## matrix using indexing, and then converts back to cellstr with mat2cell. 39 ## matrix using indexing, and then converts back to cellstr with mat2cell.
40 ## This approach is 24X faster than using cellfun with call to strtrunc 40 ## This approach is 24X faster than using cellfun with call to strtrunc
41 idx = cellfun ("size", s, 2) > n; 41 idx = cellfun ("size", s, 2) >= n;
42 rows = cellfun ("size", s(idx), 1); 42 rows = cellfun ("size", s(idx), 1);
43 s(idx) = mat2cell (char (s(idx))(:, 1:n), rows); 43 s(idx) = mat2cell (char (s(idx))(:, 1:n), rows);
44 else 44 else
45 error ("strtrunc: S must be a character string or a cell array of strings"); 45 error ("strtrunc: S must be a character string or a cell array of strings");
46 endif 46 endif