Writing data into a file when using repmat

1 次查看(过去 30 天)
I have a set of data that I generate using repmat x=5; y=[repmat(x, 1, 5)];fn=fopen('A.txt', 'w');fprintf(fn, '%g\t%g\t%g\t%g\t%g\t\r\n', y)
How do I set it up so that I do not have to type in %g\t as many times as I am using in the repmat.
Thanks for any inputs

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2011-8-26
[repmat('%g\t',1,5),'\r\n']
  3 个评论
Walter Roberson
Walter Roberson 2011-8-27
fprintf(fn, [repmat('%g\t',1,x-1) '%g\r\n'], y);

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by