⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrix2str.m

📁 hard disk drive servo control tools, it is very helpful
💻 M
字号:
function outstr = matrix2str(matrix0)
%
%   This function converts a matrix into a string
%   Its dual function : evalin('base', str)
%    
%    
outstr='[';
[nrows,ncols]=size(matrix0);
for N=1:nrows,
   outstr=[outstr,  term2str(matrix0(N,1)) ];
   for P=2:ncols,
      outstr=[outstr,  ', ', term2str(matrix0(N,P)) ];
   end 
   if N<nrows,  outstr=[outstr, '; '];        end     
end
outstr=strcat(outstr, ']');
        
if nrows<=1 & ncols<=1
   outstr=term2str(matrix0);
end   

% in case the element of the matrix is symbolic expression
function outstr = term2str(term)
if isnumeric(term) 
    outstr=num2str(term,'%0.6g');
else
    outstr=char(term);
end    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -