MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] matlab输出的2进制数之间用空格隔开 (https://www.labfans.com/bbs/showthread.php?t=21022)

hxy110 2017-04-18 09:00

matlab输出的2进制数之间用空格隔开
 
A = xlsread('Tt3.xlsx');
C = arrayfun(@(x)dec2binPN(x,17),A,'UniformOutput',false);
M = cell2mat(C);
a = strvcat(M);
[x,y] = size(a);
fid = fopen('Tt.txt','wb');
for i = 1:x
fprintf(fid,'%s\n',a(i,:));
end
fclose(fid);
程序如上,想让a的每一行都是没17个字符后显示一空格,怎么加循环,让如下加循环
A = xlsread('Tt3.xlsx');
C = arrayfun(@(x)dec2binPN(x,17),A,'UniformOutput',false);
M = cell2mat(C);
a = strvcat(M);
[x,y] = size(a);
fid = fopen('Tt.txt','wb');
for i = 1:x
for j =1:17:136
fprintf(fid,'%s\n',a(i,:));
fprintf(fid,'%s ',a(i,j:j+17));
end
end
fclose(fid);
结果只是a的从第二行起前17个字符之后有空格


所有时间均为北京时间。现在的时间是 13:00

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.