save variables in a file

1 visualización (últimos 30 días)
barbara
barbara el 9 de Mayo de 2011
I need to save in a .txt file some of the variables calculated. Each variables should occupy one column separated by tab. What is the most appropriate way of doing it?
with the line:
save('q20.txt','p','D','de','A','L','W','Per','RFF','En','D','Lm','Wm','Aratio','N2D','N3D','a','Df2D','Df3D','-ascii', '-tabs')
I save the variables in one file. But the variables are listed one below the other .
Thanks

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Mayo de 2011
fid = fopen('q20.txt','wt');
fprintf(fid, [repmat('%g\t',1,17),'%g\n'], [p(:), D(:), de(:), A(:), L(:), W(:), Per(:), RFF(:), En(:), D(:), Lm(:), Wm(:), Aratio(:), N2D(:), N3D(:), a(:), Df2D(:), Df3D(:)].' );
fclose(fid);
Note: the dot-apostrophe after the close-square-bracket is required for proper output

Más respuestas (1)

barbara
barbara el 9 de Mayo de 2011
Thank you so much

Categorías

Más información sobre File Operations 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!

Translated by