how to store variables in coloum in text file?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
SHARAD KUMAR UPADHYAY
el 26 de Mayo de 2019
Comentada: SHARAD KUMAR UPADHYAY
el 29 de Mayo de 2019
With respect sir,
%I want to stored my output variables in .txt file in coloum wise. i am using this comaand to save
save('filename.txt','variable1','variable2',etc..)
%but i got the output in rows, so please tell me how can i save my variables in coulomn?
% I save my variable in .mat file that is also saved in rows
save('filename.mat','variable1','variable2',etc..)
% Can I save output variable in both .mat and .txt format by using one line command in coulomn
0 comentarios
Respuestas (1)
darova
el 26 de Mayo de 2019
I'd use fprintf():
f = fopen('plot.txt', 'wt'); % 'wt' - write file, text mode
formspec = '%f %f\n'; % two values in a row (\n - line break)
% formspec = '%f %f %f\n'; % tree values in a row
for i = 1:3
a = rand;
b = rand;
fprintf(f, formspec, a,b);
end
fclose(f);
read about fprintf(), formatSpec. Look also for dlmwrite()
3 comentarios
darova
el 29 de Mayo de 2019
Just remove '\n' (line break)
fprintf(fileID,'%6.2e %12.8e ',output,T);
Ver también
Categorías
Más información sobre Tables 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!