Writing data into a file when using repmat

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

Answers (1)

[repmat('%g\t',1,5),'\r\n']

3 Comments

If I add the variable that I replicating, as in
[repmat('%g\t',x,1,5),'\r\n']
then the repmat syntax has an error. Thanks for your input
fprintf(fn, [repmat('%g\t',1,x-1) '%g\r\n'], y);
@Ram, what are you trying to do exactly?

Sign in to comment.

Categories

Asked:

Ram
on 26 Aug 2011

Community Treasure Hunt

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

Start Hunting!