matlab 每个cell单元后面分别加入3579个空格的程序
假设有一个3x3的矩阵A,我们可以通过以下代码在每个cell单元后面分别加入3,5,7,9个空格:
% 创建一个3x3的矩阵A
A = magic(3);
% 在每个cell单元后面分别加入3,5,7,9个空格
A_str = cellfun(@(x) [num2str(x) repmat(' ',1,3) repmat(' ',1,5) repmat(' ',1,7) repmat(' ',1,9)], num2cell(A), 'UniformOutput', false);
% 输出结果
disp(A_str)
输出结果为:
'8 ' '1 ' '6 '
'3 ' '5 ' '7 '
'4 ' '9 ' '2 '
原文地址: https://www.cveoy.top/t/topic/bRL7 著作权归作者所有。请勿转载和采集!