Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: What's wrong in my tiny little code?
Date: Sun, 21 Sep 2008 12:38:03 +0000 (UTC)
Organization: CSU
Lines: 23
Message-ID: <gb5f7b$3gg$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1222000683 3600 172.30.248.37 (21 Sep 2008 12:38:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 21 Sep 2008 12:38:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 951788
Xref: news.mathworks.com comp.soft-sys.matlab:491176


Hi -

I was wondering anything wrong in this code. It should save many files to another folder, however it just saved them in one file in which the file name is (filename(n).name). Please give me a hand.

Michael

function pad_wx_data
filename = dir ('*.txt');
n=1;
[i,j]=size(filename);
while n<i+1
x = load(filename(n).name);
[rr,cc] = size(x);
day_number = datenum(x(:,1:3));
full_day_number = [min(day_number):max(day_number)]';
y = [full_day_number NaN*ones(length(full_day_number),cc-3)];
[jnk,uix,uiy] = intersect(day_number,full_day_number);
y(uiy,2:size(y,2)) = x(uix,4:cc);
save('/Users/cks/Documents/jon/hfdata/us/WI/test/perl/test_4/out/product/(filename(n).name)', 'y')
n=n+1;
end
clear temp n i j