Thread Subject: parameterize filename

Subject: parameterize filename

From: GG

Date: 6 Jul, 2008 16:02:02

Message: 1 of 3

Hi, Is there a way to parameterize a filename in matlab?

For example, if I have 100 text files (file1.txt,
file2.txt ... file100.txt), and I want to process each
similarly, I'd like to write a loop such as,

for i=1:100
  load file(i).txt;
  data = file(i)' - mean( file(i) );
end

The reason I need to do it this way is the file size is so
large I run into out-of-memory issues if I load it in as
one big file, so I've broken it up into many smaller files.

Thanks in advance, -GG

Subject: parameterize filename

From: Lothar Schmidt

Date: 6 Jul, 2008 17:06:08

Message: 2 of 3

GG schrieb:
> Hi, Is there a way to parameterize a filename in matlab?
>
> For example, if I have 100 text files (file1.txt,
> file2.txt ... file100.txt), and I want to process each
> similarly, I'd like to write a loop such as,
>
> for i=1:100
> load file(i).txt;
> data = file(i)' - mean( file(i) );
> end
>
> The reason I need to do it this way is the file size is so
> large I run into out-of-memory issues if I load it in as
> one big file, so I've broken it up into many smaller files.
>
> Thanks in advance, -GG

for i=1:100
filename=['file' num2str(i) '.txt'];
data=readfunction(filename);

result=dowatheveryouwantto(data);
perhapsoutputfunction(result);
end

Subject: parameterize filename

From: Peter Boettcher

Date: 7 Jul, 2008 15:02:25

Message: 3 of 3

"GG " <ggkmath@comcast.net> writes:

> Hi, Is there a way to parameterize a filename in matlab?
>
> For example, if I have 100 text files (file1.txt,
> file2.txt ... file100.txt), and I want to process each
> similarly, I'd like to write a loop such as,
>
> for i=1:100
> load file(i).txt;
> data = file(i)' - mean( file(i) );
> end
>
> The reason I need to do it this way is the file size is so
> large I run into out-of-memory issues if I load it in as
> one big file, so I've broken it up into many smaller files.

for i=1:100
  filename = sprintf('file%i.txt', i);
  data = load(filename);

  processed_data = data' - mean(data);
end


-Peter

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
parameterize fi... GG 6 Jul, 2008 12:05:05
rssFeed for this Thread

Contact us at files@mathworks.com