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:
Saving matrix content to .txt

Subject: Saving matrix content to .txt

From: Ulrik Nash

Date: 9 Jun, 2011 15:59:05

Message: 1 of 2

Hi Everyone,

Suppose I wish to save the content of a matrix, M, to text:

dlmwrite(filename, M)

Suppose further that saving occurs at the end of a loop, say of 10 n iterations.

My question is, since I do not wish to overwrite the content of 'filename', how can I make the filename incorporate the iteration number. Eg. filename_8.txt

Regards,

Ulrik.

Subject: Saving matrix content to .txt

From: Md Sahidullah

Date: 16 Jun, 2011 05:03:05

Message: 2 of 2

"Ulrik Nash" <uwn@sam.sdu.dk> wrote in message <isqqk9$o00$1@newscl01ah.mathworks.com>...
> Hi Everyone,
>
> Suppose I wish to save the content of a matrix, M, to text:
>
> dlmwrite(filename, M)
>
> Suppose further that saving occurs at the end of a loop, say of 10 n iterations.
>
> My question is, since I do not wish to overwrite the content of 'filename', how can I make the filename incorporate the iteration number. Eg. filename_8.txt
>
> Regards,
>
> Ulrik.

Hi Ulrik,

for i=1:TotalIterations
...
filename=strcat('Filename','_',num2str(i));
then use dlmwrite function.
...
end

Thanks & Regards
Sahid

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