1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| [FileName,PathName] = uigetfile('*.txt','sélectionnez les fichiers texte', 'MultiSelect', 'on');
fid = fopen(fullfile(PathName,FileName{1}), 'r');
T1 = textscan(fid, '%s', 1, 'delimiter', '\n', 'headerlines', 1);
X1 = textscan(fid, '%s', 'delimiter', '\n');
fclose(fid);
for n = 2:numel(FileName)
fid = fopen(fullfile(PathName,FileName{n}), 'r');
T2(n-1) = textscan(fid, '%s', 1, 'delimiter', '\n', 'headerlines', 1);
X2(n-1) = textscan(fid, '%*d%s', 'delimiter', '\n');
fclose(fid);
end
T = strcat(T1{1}, T2{1}{1}(5:end));
X = strcat(X1{1}, {9}, X2{1});
for n = 2:numel(FileName)-1
T{1} = strcat(T{1}, T2{n}{1}(5:end));
X = strcat(X, X2{n});
end
fid = fopen('test.txt', 'wt');
fprintf(fid, '#%d\t', 1:10*numel(FileName));
fprintf(fid, '\n%s\n', T{1});
fprintf(fid, '%s\n', X{:});
fclose(fid);
edit test.txt |
Partager