📄 vec2str.m
字号:
function str=vec2str(v,form)
%VEC2STR Converts vector to string array.
% VEC2STR(V,'form') returns a string array with
% one row for each number in the vector, V.
% The input argument 'form' is optional and specifies
% the format for the number to string conversion.
% If 'form' is missing the default ' %.4g' is used.
% This gives a leading space befor the number.
% See SPRINTF in a C manual for valid formats.
% Dr M.P. Ford 4th August 1987
% Copyright (c) 1987 by GEC Engineering Research Centre & Cambridge Control Ltd
nargs=nargin;
error(nargchk(1,2,nargs));
if nargs==1
form=' %.4g';
end
blank=' ';
str=sprintf(form,v(1));
lstr=length(str);
for i=2:length(v)
st=sprintf(form,v(i));
lst=length(st);
if lst>lstr
[m,n]=size(str);
str=[str,setstr(blank.*ones(m,lst-n))];
lstr=lst;
else
st=[st,setstr(blank.*ones(1,lstr-lst))];
end
str=[str;st];
end % for i=1:length(v)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -