Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Spaced headers with dlmwrite

Subject: Spaced headers with dlmwrite

From: Daphne W

Date: 11 Aug, 2007 15:07:26

Message: 1 of 3


I am using dlmwrite to create a txt file that is exported
into excel. The txt includes text headers and number
matrices.
So far I have been creating a single text header that
includes all the titles that a line in excel will have,
and spacing the titles manually....
Is there a way to get each title tabbed from the one
preceeding it?
If I use the '\t' option each letter in the title gets a
tab and gets put into a different cell in excel.

Thanks,
Daphne

Subject: Spaced headers with dlmwrite

From: us

Date: 12 Aug, 2007 10:20:08

Message: 2 of 3

Daphne:
<SNIP <dlmwrite> conundrum...

one of the solutions

% the data
     fnam='foo.txt'; % <- your data file
     hdr={'a','bb','ccc'};
     m=magic(3);
% the engine
     txt=sprintf('%s\t',hdr{:});
     txt(end)='';
     dlmwrite(fnam,txt,'');
     dlmwrite(fnam,m,'-append','delimiter','\t');
% the result
     type(fnam)

us

Subject: Spaced headers with dlmwrite

From: Daphne

Date: 12 Aug, 2007 13:56:39

Message: 3 of 3


Works great. Thanks !
Now I have to re-figure my alignments...

Daphne


"us " <us@neurol.unizh.ch> wrote in message
<f9mmso$75h$1@fred.mathworks.com>...
> Daphne:
> <SNIP <dlmwrite> conundrum...
>
> one of the solutions
>
> % the data
> fnam='foo.txt'; % <- your data file
> hdr={'a','bb','ccc'};
> m=magic(3);
> % the engine
> txt=sprintf('%s\t',hdr{:});
> txt(end)='';
> dlmwrite(fnam,txt,'');
> dlmwrite(fnam,m,'-append','delimiter','\t');
> % the result
> type(fnam)
>
> us

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us