How to combine cells with a matrix?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
rui gao
el 30 de En. de 2019
Comentada: rui gao
el 31 de En. de 2019
I want to extract 6 lines from a ascii file, and add these lines into another text file which just contains a matrix, like 500*500.
Now, I extract the first 6 lines from the ascii file:
%% extract title for the new ascii file
fid = fopen('filename','r')
numLines = 6; % I knew there are 6 lines I need
title = cell(numLines,1);
for ii = 1:numLines
title(ii) = {fgetl(fid)};
end
fclose(fid);
Q1: how to combine these lines with another matrix to generate a new text file?
Q2: how to output this new text file?
Any help would be appreciated.
0 comentarios
Respuesta aceptada
KSSV
el 30 de En. de 2019
Read about fprintf and dlmwrite. First write the text lines and then write the matrix.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Text Data Preparation 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!