Re: Dataset Arrays or...?
- From: "Ian Clarkson" <ian.clarkson@xxxxxxxxxxxxxx>
- Date: Mon, 21 Jan 2008 18:59:02 +0000 (UTC)
"Robert " <river_doctor@xxxxxxxxxxx> wrote in message
<fn2jfl$b2b$1@xxxxxxxxxxxxxxxxxx>...
Ok, as a Newbie I seem to be getting stuck on theunderlying
structure of arrays etc. Data that I work with alwayshas a
time stamp in the first column and different measuredperform
variables in subsequent columns. Although I need to
statistics on the entire dataset, I also need summaryQ)
statistics over various time periods (e.g. monthly stats).
Daily data will be in the form:
2005/12/25 2.959
2005/12/26 2.894
2005/12/27 2.879
2005/12/28 2.894
2005/12/29 2.837
2005/12/30 2.775
2005/12/31 2.825
etc...
In an .m file I am loading such data using,
[date,Q] = textread(File,'%s %f','delimiter',',');
And see that I can separate the date fields using,
[y, m, d] = datevec(date);
I assumed that I would then concatenate my vectors (y m d
so that I could extract Q for the time period required(e.g.
all Januaries). I would appreciate advice on whether I amhave
approaching this correctly and what method is best for the
summaries I require (e.g. subsets? using grouping?). I
tried too many things to list here but I am assuming thatright
this is very simple and someone could set me straight
away.
Many thanks.
try something like this:
% read in the data
data=textread('c:\data.txt','%s')
% split into dates and Q values
dates = data(1:2:end);
Q = data(2:2:end);
% get from cell into arrays
for i = 1:length(dates)
ymd(:,i) = sscanf(dates{i},'%d/%d/%d');
Qs(i) = sscanf(Q{i},'%f');
end;
% now you've got vectors for everything
years = ymd(1,:);
months = ymd(2,:);
days = ymd(3,:);
qvals = Qs(1,:);
.
- References:
- Dataset Arrays or...?
- From: Robert
- Dataset Arrays or...?
- Prev by Date: Re: panel data
- Next by Date: Matlab 64 bit Multicore test
- Previous by thread: Dataset Arrays or...?
- Next by thread: numerical fourier transform of an error function
- Index(es):
Relevant Pages
|