Skip to content

Commit

Permalink
D with 1 ouput replaces most input characters below 32 by space
Browse files Browse the repository at this point in the history
`D` with 1 output now replaces most input characters below 32 by space
(similar to what happens with `0` outputs).

Corrected mat2str_comp, so that it doesn't remove trailing spaces
  • Loading branch information
lmendo committed May 22, 2017
1 parent 7d82d8a commit bf56e47
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions compatibility/mat2str_comp.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
if severalRows
z = num2cell(varargin{1},2);
z = regexprep(z, '''', '''''');
z = strcat('''', z, ''';');
z = strcat('''', z, ''';'); % We use strcat here because z is a cell array. Trailing spaces are correctly preserved
z = horzcat(z{:});
z = [ '[' z(1:end-1) ']'];
else
z = regexprep(varargin{1}, '''', '''''');
z = strcat('''', z, '''');
z = horzcat('''', z, ''''); % We use horzcat here because z is a string, and trailing spaces would be incorrectly removed by strcat
end
else
z = builtin('mat2str', varargin{:});
Expand Down
Binary file modified funDef.mat
Binary file not shown.
4 changes: 2 additions & 2 deletions funDef.txt
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ ZC 2 3 2 1 1 1 true true true true if numel(in{2})==1, if size(in{1},1)==1, in
else
out{1} = im2col(in{:});
end
D 0 inf 1 0 1 0 1 true true true true if nout==0 convert to string and display / string representation (i) With $0$ outputs: If $1$ input: \matlab+disp(num2str(..., '%.15g '))+. If several inputs: \matlab+disp(num2str(eachInput,lastInput))+, where \matlab+eachInput+ loops over all inputs but the last. In either case, (nested) cell arrays are (recursively) unboxed in linear order. Most characters below 32 are replaced by space. (ii) With $1$ output: \matlab+mat2str+. Empty arrays are always shown as \matlab+[]+, \matlab+''+ or \matlab+{}+. Cell arrays are converted to string representation too. Optional second, third and fourth inputs respectively specify column separator, row separator and whether the column separator should be used for non-cell arrays too. Second and third output are converted to char is needed. \sa \matl+XD+, \matl+YD+, \matl+ZD+
D 0 inf 1 0 1 0 1 true true true true if nout==0 convert to string and display / string representation (i) With $0$ outputs: If $1$ input: \matlab+disp(num2str(..., '%.15g '))+. If several inputs: \matlab+disp(num2str(eachInput,lastInput))+, where \matlab+eachInput+ loops over all inputs but the last. In either case, (nested) cell arrays are (recursively) unboxed in linear order. Most characters below 32 are replaced by space. (ii) With $1$ output: \matlab+mat2str+. Empty arrays are always shown as \matlab+[]+, \matlab+''+ or \matlab+{}+. Most input characters below 32 are replaced by space. Cell arrays are converted to string representation too. Optional second, third and fourth inputs respectively specify column separator, row separator and whether the column separator should be used for non-cell arrays too. Second and third output are converted to char is needed. \sa \matl+XD+, \matl+YD+, \matl+ZD+
if numel(in)==1, data = in; fmt = {'%.15g '}; else data = in(1:end-1); fmt = in(end); end
kk = cellfun(@iscell, data);
while any(kk)
Expand All @@ -650,7 +650,7 @@ D 0 inf 1 0 1 0 1 true true true true if nout==0 convert to string and display
if isempty(y{n})
done = false;
if ~iscell(x{1})
if isempty(x{1}), if ischar(x{1}), s = ''''''; else, s = '[]'; end; else s = mat2str(x{1}); end
if isempty(x{1}), if ischar(x{1}), s = ''''''; else, s = '[]'; end; else, if ischar(x{1}), x{1}(ismember(x{1},replaceBySpace)) = ' '; end; s = mat2str(x{1}); end
if sep_noncell
for k = flip(find(~mod(cumsum(s==''''),2) & s==' ')), s = [s(1:k-1) col_sep s(k+1:end)]; end
for k = flip(find(~mod(cumsum(s==''''),2) & s==';')), s = [s(1:k-1) row_sep s(k+1:end)]; end
Expand Down
Binary file modified help.mat
Binary file not shown.
Binary file modified spec/MATL_spec.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion spec/funDefTable/funDefTable.tex
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
\matl{XC} & 1--7 (2) & 1--3 (1) & \matlab+histcounts+ \\
\matl{YC} & 2--4 (2) & 1 & \matlab+im2col+. If the second input is a scalar \matlab+n+, it is transformed into \matlab+[1 n]+ if the first input is a row vector, or to \matlab+[n 1]+ otherwise. First input can also be a cell array. \sa \matl{ZC} \\
\matl{ZC} & 2--3 (2) & 1 & \matlab+im2col(..., 'distinct')+. If the second input is a scalar n, it is transformed into [1 n] if the first input is a row vector, or to [n 1] otherwise. First input can also be a cell array. \sa \matl{YC} \\
\matl{D} & 0-- (1) & 0--1 (0 / 1) & (i) With $0$ outputs: If $1$ input: \matlab+disp(num2str(..., '%.15g '))+. If several inputs: \matlab+disp(num2str(eachInput,lastInput))+, where \matlab+eachInput+ loops over all inputs but the last. In either case, (nested) cell arrays are (recursively) unboxed in linear order. Most characters below 32 are replaced by space. (ii) With $1$ output: \matlab+mat2str+. Empty arrays are always shown as \matlab+[]+, \matlab+''+ or \matlab+{}+. Cell arrays are converted to string representation too. Optional second, third and fourth inputs respectively specify column separator, row separator and whether the column separator should be used for non-cell arrays too. Second and third output are converted to char is needed. \sa \matl{XD}, \matl{YD}, \matl{ZD} \\
\matl{D} & 0-- (1) & 0--1 (0 / 1) & (i) With $0$ outputs: If $1$ input: \matlab+disp(num2str(..., '%.15g '))+. If several inputs: \matlab+disp(num2str(eachInput,lastInput))+, where \matlab+eachInput+ loops over all inputs but the last. In either case, (nested) cell arrays are (recursively) unboxed in linear order. Most characters below 32 are replaced by space. (ii) With $1$ output: \matlab+mat2str+. Empty arrays are always shown as \matlab+[]+, \matlab+''+ or \matlab+{}+. Most input characters below 32 are replaced by space. Cell arrays are converted to string representation too. Optional second, third and fourth inputs respectively specify column separator, row separator and whether the column separator should be used for non-cell arrays too. Second and third output are converted to char is needed. \sa \matl{XD}, \matl{YD}, \matl{ZD} \\
\matl{XD} & 0-- ($^\ddagger$ / 1) & 0 & \matlab+disp(num2str(eachInput, '%.15g '))+, where \matlab+eachInput+ loops over all inputs. (Nested) cell arrays are (recursively) unboxed in linear order. Most characters below 32 are replaced by space. \sa \matl{D}, \matl{YD}, \matl{ZD} \\
\matl{YD} & 1-- (2 / 1) & 0--2 (1 / 0) & \matlab+sprintf+. If $0$ outputs: prints to screen using \matlab+fprintf(...)+. \sa \matl{D}, \matl{XD}, \matl{ZD} \\
\matl{ZD} & 0-- (1) & 0 & \matlab+disp+ for each input. For char input, most characters below 32 are replaced by space. \sa \matl{D}, \matl{XD}, \matl{YD} \\
Expand Down

0 comments on commit bf56e47

Please sign in to comment.