How do I format and write a numeric array to a file as text?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
What's the easies way to write an array to a formatted file. If I have 16 columns, it seems cumbersome that I have to specify the individual format for each column and then print it in a for loop. Isn't there something like this?
Arrayprint(fid,Data,'f10.5')
thanks
0 comentarios
Respuestas (3)
Jan
el 5 de Jul. de 2011
DLMWRITE can create such files. But FPRINTF is vectorized also, so you do not need a loop:
x = rand(100, 16);
fmt = [repmat('%10.5f ', 1, 15), '%10.5f\n'];
fid = fopen(FileName, 'w');
fprintf(fid, fmt, x'); % transposed!
fclose(fid);
0 comentarios
Ver también
Categorías
Más información sobre Cell Arrays en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!