how can i create a .txt file from vectors with different length?

5 次查看(过去 30 天)
I need to create a txt file with vector having different lenght. I wrote this code but the position of each cell is changed.
fileID = fopen('BN_for_prediciting_zeros_argilliti_v1.sae','w');
fprintf(fileID,'L_mean_argil, L_Min_argil, L_Max_argil, R_mean_argil, R_Min_argil, R_Max_argil, Zero_argil\n');
fprintf(fileID,'%6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f, %6.4f \n', L_mean_argil, L_Min_argil, L_Max_argil, R_mean_argil, R_Min_argil, R_Max_argil, Zero_argil');
fclose(fileID);
Can someone help me?

回答(1 个)

madhan ravi
madhan ravi 2018-11-2
编辑:madhan ravi 2018-11-2
a=1:10 %an example assuming datas are numeric
b=1:15
dlmwrite('sample.txt',a,'delimiter')
dlmwrite('sample.txt',b,'delimiter','-append')
  1 个评论
EM geo
EM geo 2018-11-2
编辑:EM geo 2018-11-2
tnk you for the reply. I wrote this code:
a = L_mean_argil %an example assuming datas are numeric
b = R_Min_argil
dlmwrite('sample.txt',a,'precision','%6.4f','coffset',1)
dlmwrite('sample.txt',b,'precision','%6.4f','coffset',1)
but it write only the second matrix (b). How can i add the first one too? With append it insert the second colum behind the first but i need a column for each variable, and i need the name of the variable too (in the first row).

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by