Path: news.mathworks.com!not-for-mail
From: "Sean de " <sean.dewolski@nospamplease.umit.maine.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Data Subsampling
Date: Tue, 23 Nov 2010 20:39:05 +0000 (UTC)
Organization: University of Maine
Lines: 16
Message-ID: <ich8p9$fgj$1@fred.mathworks.com>
References: <ich2vm$mbl$1@fred.mathworks.com> <ich5cg$22r$1@fred.mathworks.com> <ich6cc$6j9$1@fred.mathworks.com> <ich6v4$flh$1@fred.mathworks.com> <ich8c4$if5$1@fred.mathworks.com>
Reply-To: "Sean de " <sean.dewolski@nospamplease.umit.maine.edu>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1290544745 15891 172.30.248.38 (23 Nov 2010 20:39:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 23 Nov 2010 20:39:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2256903
Xref: news.mathworks.com comp.soft-sys.matlab:689445


> > data(:,1) = data(:,1)-min(data(:,1))+1; %normalize so 1974 is 1
> > 
> > new_data_matrix = accumarray(data(:,[1 2]),data(:,3));
> > 
> > each row of the new matrix will be the year (1:37) and the columns will be the 366 days.
> > 
> > You could also do:
> > new_data_matrix = zeros(37,366);
> > new_data_matrix(sub2ind([37 366],data(:,1),data(:,2))) = data(:,3);
> 
> Thanks Sean - what I get with the first approach is a matrix of zeros from Row 0 to 1973  by 366 columns and then the data appears. Is there a way to get Matlab to ignore Rows 0 to 1973? Thanks for your help.

That was the point of this line.  It makes the year 1974 = 1, thus making it the first row.

data(:,1) = data(:,1)-min(data(:,1))+1; %normalize so 1974 is 1