Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Combining series of matrices
Replies: 10   Last Post: Jan 26, 2013 10:05 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
dpb

Posts: 8,260
Registered: 6/7/07
Re: Combining series of matrices
Posted: Jan 22, 2013 10:35 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 1/21/2013 4:12 PM, dpb wrote:
> On 1/20/2013 11:30 AM, Ehsan wrote:
>> "james bejon" wrote in message <kdh908$g0c$1@newscl01ah.mathworks.com>...
>>> If you supply some code that generates the relevant data structure,
>>> I'll happily have a go...

>>
> ...
>
> Lum.data=[];


...Previous code elided for brevity to correct a syntax problem of
concatenating a structure w/ an array...
>
> Salt to suit...


Concatenate the L and R arrays then create the structure in the end--

L=[];
R=[];
while date<=end_date
filename=sprintf('SS%s.csv',datestr(date,'yymmdd'));
d=importdata(filename,',',9);
nr=size(d.data(:,2));
time=zeros(nr,1);
time=datenum(d.textdata(10:nr+9,2),'HH:MM:ss');
time=date+time-735235;
d.data=[datevec(time),d.data];
L=d.data(1:2:end,:);
R=d.data(2:2:end,:);
L(L(:,1)==0)=[];
R(R(:,1)==0)=[];
L=[L;L];
R=[R;R];
date=date+1;
end
Lum.data=L;
Rad.data=R;

NB that if there are a large number and/or they are large, this will get
slow as it grows. If you know the sizes a priori you can help by
preallocating a large-enough array and populate it explicitly w/ ranges.
Keeping the full sizes and then collapsing the null entries at the end
before creating the structure may also be faster than doing each first;
I've not tested that w/ any random data to see if can tell any
significant difference.

--




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.