Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: How to write multiple files (.dat or .txt) with consecutive file
names in matlab

Replies: 2   Last Post: Mar 11, 2013 11:32 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Derek Goring

Posts: 3,892
Registered: 12/7/04
Re: How to write multiple files (.dat or .txt) with consecutive file
names in matlab

Posted: Mar 11, 2013 4:32 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Monday, March 11, 2013 4:41:09 PM UTC+13, Kris wrote:
> I have the following scenario:
>
>
>
> for t = 1:10 % As time goes from 1 to 10.
>
>
>
> for i = 1:10 % As position goes from 1 to 10.
>
>
>
> u(i) = some operation
>
>
>
> end
>
>
>
>
>
> s = u'; % Just getting a transpose so i can read the data better.
>
>
>
> save ("File(i).txt', 's', '-ascii', '-tabs');
>
>
>
> % I know this doesn't work. I need a help with this.
>
>
>
> end
>
>
>
> Desired output:
>
>
>
> File1 : with data at t = 1 and i = 1:10.
>
> File 2: with data at t=2 and i = 1:10;
>
> and so on.
>
>
>
>
>
> How to save multiple files using a for loop, or any other method would would also work.


You're almost there.........
txtfile=['File' num2str(i) '.txt']; % Need to convert index to string
save (txtfile, 's', '-ascii', '-tabs');



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.