Functions | |
endif | if (ischar(x)) retval |
elseif (isempty(x)) retval | |
elseif (iscomplex(x)) if(nargin | |
else | if (isnumeric(x)&&round(x)==x &&abs(x)< (10.^arg)) fmt |
if (length(abs(x)==x) > 0) fmt | |
endif | elseif (isscalar(x)) fmt = "%11.5g" |
perm (2:2:2 *nc) | |
while (true) tmp2 | |
if (length(tmp)==length(tmp2)) break | |
if (tmp==tmp2) break | |
endif endwhile | tmp (length(tmp)) |
else | if (nargin==2) if(ischar(arg)) fmt |
endif endfunction | !assert ((strcmp(num2str(123),"123")&&strcmp(num2str(1.23),"1.23"))) |
!assert (num2str(123.456, 4),"123.5") | |
!assert (all(num2str([1, 1.34;3, 3.56],"%5.1f")==["1.0 1.3";"3.0 3.6"])) | |
!assert (num2str(1.234+27.3i),"1.234+27.3i") | |
!error | num2str () |
!error | num2str (1, 2, 3) |
Variables | |
function | retval |
else | fmt = sprintf ("%%%d.%dg%%-+%d.%dgi", arg+7, arg, arg+7, arg) |
endif endif else if(isnumeric(x)&&round(x)==x &&abs(x)< 1e10) if(max(abs(real(x(else | dgt1 |
endif | dgt2 = dgt1 - (min (real (x(:))) >= 0) |
endif endif | sz = size (x) |
nc = sz(2) | |
nd = ndims (x) | |
perm = fix ([1:0.5:nc+0.5]) | |
idx = cell () | |
for | i |
x = horzcat (real (x), imag (x)) | |
tmp = sprintf (fmt, permute (x, [2, 1, 3:nd])) | |
endif endif else if(isnumeric(x)&&round(x)==x &&abs(x)< 1e10) if(max(abs(x(else | dgt = floor (log10 (max (abs(x(:))))) + (min (real (x(:))) < 0) + 2 |
!assert | ( | num2str(1.234+27.3i) | , | |
"1.234+27.3i" | ||||
) |
!assert | ( | all(num2str([1, 1.34;3, 3.56],"%5.1f")==["1.0 1.3";"3.0 3.6"]) | ) |
!assert | ( | num2str(123.456, 4) | , | |
"123.5" | ||||
) |
endif endfunction !assert | ( | (strcmp(num2str(123),"123")&&strcmp(num2str(1.23),"1.23")) | ) |
endif elseif | ( | isscalar(x) | ) | = "%11.5g" |
elseif | ( | iscomplex(x) | ) |
elseif | ( | isempty(x) | ) |
if | ( | tmp | = =tmp2 |
) |
if | ( | length(tmp) | = =length(tmp2) |
) |
if | ( | length(abs(x)==x) | , | |
0 | ||||
) |
else if | ( | ) |
endif if | ( | ischar(x) | ) |
!error num2str | ( | 1 | , | |
2 | , | |||
3 | ||||
) |
!error num2str | ( | ) |
perm | ( | 2:2:2 * | nc | ) |
while | ( | true | ) |
endif endif else if (isnumeric (x) && round (x) == x && abs (x) < 1e10) if (max (abs (x( else dgt = floor (log10 (max (abs(x(:))))) + (min (real (x(:))) < 0) + 2 |
idx = cell () |
nc = sz(2) |
perm = fix ([1:0.5:nc+0.5]) |
x = horzcat (real (x), imag (x)) |