Creating a file from different-sized files.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Nada
el 22 de Feb. de 2023
Respondida: William Rose
el 22 de Feb. de 2023
Hi to all
I have these files consisting of two variabilities, so I want to create one formatted text file
start from the Line_2.mat, it will be the four rows of a now_file, then from the second file TT.txt, I want to add the table to now_file.
1 comentario
Anton Kogios
el 22 de Feb. de 2023
Which variable in Line_2.mat are you talking about? And have you made an attempt at solving this? If so, post your code.
Respuesta aceptada
William Rose
el 22 de Feb. de 2023
Line_2.mat contains several variables. Let's assume you are interested in the one called Data. To append the data in TT.txt, do the following:
load('Line_2.mat'); % loads all the data in Line_2.mat
A=importdata('TT.txt'); % structure A contains the headers and the data
DataAll=[Data;A.data]; % combine
fprintf('Size of Data=%d x %d.',size(Data))
fprintf('Size of A.data=%d x %d.',size(A.data))
fprintf('Size of DataAll=%d x %d.',size(DataAll))
save('DataAll.txt','DataAll','-ascii') %save combined data to text file
Try it. Good luck.
0 comentarios
Más respuestas (1)
Kevin Holly
el 22 de Feb. de 2023
Did you want something like this? Note, I attached an import function called importTTfile.
load('Line_2.mat')
TT = importTTfile('TT.txt')
writetable(TT,'now_file','FileType','text')
Line_2 = table2array(Line_2)
fid = fopen('now_file.txt', 'a+');
fprintf(fid, Line_2{1});
fprintf(fid, Line_2{2});
fclose(fid);
0 comentarios
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!