<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Processing a Set of Files</title>
	<link>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/</link>
	<description>Loren Shure  works on design of the MATLAB language at &#60;a href="http://www.mathworks.com/"&#62;The MathWorks&#60;/a&#62;. She writes here about once a week on MATLAB programming and related topics. &#60;br&#62;&#60;br&#62;&#60;a href="/images/loren-full.jpg"&#62;&#60;img src="/images/loren.jpg"&#62;&#60;/a&#62;</description>
	<pubDate>Sun, 08 Nov 2009 05:43:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-24317</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 04 Jan 2008 12:09:44 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-24317</guid>
		<description>Ibrahim-

Use the functional form for writing your report and build up the filename, something like this:

&lt;pre class="code"&gt;
for n = 1:numFiles
  fn = ['report', int2str(n), '.xls');
  % now use this filename, e.g.,
  xlswrite(fn, ...)
end

&lt;/pre&gt;

--Loren</description>
		<content:encoded><![CDATA[<p>Ibrahim-</p>
<p>Use the functional form for writing your report and build up the filename, something like this:</p>
<pre class="code">
for n = 1:numFiles
  fn = ['report', int2str(n), '.xls');
  % now use this filename, e.g.,
  xlswrite(fn, ...)
end
</pre>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ibrahim</title>
		<link>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-24308</link>
		<dc:creator>ibrahim</dc:creator>
		<pubDate>Fri, 04 Jan 2008 07:47:42 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-24308</guid>
		<description>I run my program n times, each time I want to save run report in a file called test_report.xls. during the run time, the file should be test_report1.xls, test_report2.xls, ....,test_reportn.xls. please let me know how can I do that (adding 1, 2 ,...,n to the file name)

Thanks
Ibrahim</description>
		<content:encoded><![CDATA[<p>I run my program n times, each time I want to save run report in a file called test_report.xls. during the run time, the file should be test_report1.xls, test_report2.xls, &#8230;.,test_reportn.xls. please let me know how can I do that (adding 1, 2 ,&#8230;,n to the file name)</p>
<p>Thanks<br />
Ibrahim</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-16300</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Wed, 27 Jun 2007 01:56:50 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-16300</guid>
		<description>MJ-

Got any guesses since it's wavwrite to write them out?  Try using lookfor at the MATLAB prompt or searching the doc.  What happens if you look up wavwrite?  Does it help you at all?

--loren</description>
		<content:encoded><![CDATA[<p>MJ-</p>
<p>Got any guesses since it&#8217;s wavwrite to write them out?  Try using lookfor at the MATLAB prompt or searching the doc.  What happens if you look up wavwrite?  Does it help you at all?</p>
<p>&#8211;loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MJ</title>
		<link>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-16299</link>
		<dc:creator>MJ</dc:creator>
		<pubDate>Tue, 26 Jun 2007 20:42:44 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-16299</guid>
		<description>How do I import WAV files into MATLAB for analysis of sound waves?</description>
		<content:encoded><![CDATA[<p>How do I import WAV files into MATLAB for analysis of sound waves?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jerker Wågberg</title>
		<link>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-9032</link>
		<dc:creator>Jerker Wågberg</dc:creator>
		<pubDate>Fri, 25 Aug 2006 13:19:31 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-9032</guid>
		<description>Is it allowed to shamefully plug for my own contribution in FileExchange in this context? Filefun will handle these kind of tasks in a seemingly vectorized fashion á la cellfun et al.

Jerker
------
Yupp, that's my name. Same as the IKEA desk.</description>
		<content:encoded><![CDATA[<p>Is it allowed to shamefully plug for my own contribution in FileExchange in this context? Filefun will handle these kind of tasks in a seemingly vectorized fashion á la cellfun et al.</p>
<p>Jerker<br />
&#8212;&#8212;<br />
Yupp, that&#8217;s my name. Same as the IKEA desk.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: StephenL.CSSM</title>
		<link>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-8705</link>
		<dc:creator>StephenL.CSSM</dc:creator>
		<pubDate>Fri, 18 Aug 2006 14:31:42 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-8705</guid>
		<description>Brad:  Thanks.  Agree about the speed.  I put in a enhancement request in for this.

Michael:  Thanks.  That's perfect.  To get to the end result needed: [nameWithSpace{:}] strings everything out into a char array.

Stephen</description>
		<content:encoded><![CDATA[<p>Brad:  Thanks.  Agree about the speed.  I put in a enhancement request in for this.</p>
<p>Michael:  Thanks.  That&#8217;s perfect.  To get to the end result needed: [nameWithSpace{:}] strings everything out into a char array.</p>
<p>Stephen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-8663</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Fri, 18 Aug 2006 07:16:50 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-8663</guid>
		<description>@StephenL:

You can have the concatenation even easier, without resorting to arrayfun and anonymous functions:

files = dir(’*.mat’);
namesWithSpace = strcat(newpath,{files.name},{' '});

Michael</description>
		<content:encoded><![CDATA[<p>@StephenL:</p>
<p>You can have the concatenation even easier, without resorting to arrayfun and anonymous functions:</p>
<p>files = dir(’*.mat’);<br />
namesWithSpace = strcat(newpath,{files.name},{&#8217; &#8216;});</p>
<p>Michael</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brad phelan</title>
		<link>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-7516</link>
		<dc:creator>brad phelan</dc:creator>
		<pubDate>Thu, 10 Aug 2006 09:42:13 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-7516</guid>
		<description>To stephen.

I think this maybe what you want

% arr - the n-dimensional input matrix
% dim - the dimension to iterate over
% fh  - the function handle to process the iteration
function iterate_dim(arr, dim, fh)
...n = ndims(arr);
...m = size(arr, dim);
...idx = repmat({':'}, n);
...for i = 1:m
......idx{dim}=i;
......r = arr(idx{:});
......fh(r);
...end
end

to use

a = rand(10);
iterate_dim(a, 1, @(row) disp(row))
iterate_dim(a, 2, @(col) disp(col))

I have not checked the code above so I don't know if it works as advertised :). Also I think the inner indexing
will be slow as matlab will not be able to JIT the indexing. Is there a smarter way to do the indexing?

B</description>
		<content:encoded><![CDATA[<p>To stephen.</p>
<p>I think this maybe what you want</p>
<p>% arr - the n-dimensional input matrix<br />
% dim - the dimension to iterate over<br />
% fh  - the function handle to process the iteration<br />
function iterate_dim(arr, dim, fh)<br />
&#8230;n = ndims(arr);<br />
&#8230;m = size(arr, dim);<br />
&#8230;idx = repmat({&#8217;:'}, n);<br />
&#8230;for i = 1:m<br />
&#8230;&#8230;idx{dim}=i;<br />
&#8230;&#8230;r = arr(idx{:});<br />
&#8230;&#8230;fh(r);<br />
&#8230;end<br />
end</p>
<p>to use</p>
<p>a = rand(10);<br />
iterate_dim(a, 1, @(row) disp(row))<br />
iterate_dim(a, 2, @(col) disp(col))</p>
<p>I have not checked the code above so I don&#8217;t know if it works as advertised :). Also I think the inner indexing<br />
will be slow as matlab will not be able to JIT the indexing. Is there a smarter way to do the indexing?</p>
<p>B</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-6839</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Tue, 08 Aug 2006 17:00:12 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-6839</guid>
		<description>Gary-

wav-files use a losy compression scheme so when you read the data back in, it doesn't match the mat-file data exactly. 

But I think you are pointing my mistake in the M-code!  The for loop &lt;b&gt;should&lt;/b&gt; read

&lt;pre class="code"&gt;
%% Loops over the Files
% 
for ind = 2:length(matfiles)
    data = load(matfiles(ind).name);
    wavwrite(data.y,data.Fs,matfiles(ind).name(1:end-4));
end
&lt;/pre&gt;

I have fixed up that and another small bug in the code in the blog itself.

--Loren</description>
		<content:encoded><![CDATA[<p>Gary-</p>
<p>wav-files use a losy compression scheme so when you read the data back in, it doesn&#8217;t match the mat-file data exactly. </p>
<p>But I think you are pointing my mistake in the M-code!  The for loop <b>should</b> read</p>
<pre class="code">
%% Loops over the Files
%
for ind = 2:length(matfiles)
    data = load(matfiles(ind).name);
    wavwrite(data.y,data.Fs,matfiles(ind).name(1:end-4));
end
</pre>
<p>I have fixed up that and another small bug in the code in the blog itself.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary Roth</title>
		<link>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-6837</link>
		<dc:creator>Gary Roth</dc:creator>
		<pubDate>Tue, 08 Aug 2006 16:50:41 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2006/08/02/processing-a-set-of-files/#comment-6837</guid>
		<description>Did you try to play the resulting .wav files?  I did, and they sounded funny.</description>
		<content:encoded><![CDATA[<p>Did you try to play the resulting .wav files?  I did, and they sounded funny.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
