Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
More efficient way to accumulate the data

Subject: More efficient way to accumulate the data

From: edward kabanyas

Date: 15 Dec, 2011 05:28:08

Message: 1 of 4

Hi All;

I have a monthly data, with the structure as:

year month date hour latitude data (401 coulumn)
10 11 1 0 -10 1 1 .....401th
10 11 1 0 -9.8 0 0 .....401th
10 11 1 0 -9.6 1 0 .....401th
............................
10 11 1 0 10 1 0 .....401th
10 11 1 1 -10 1 1 .....401th
10 11 1 1 -9.8 0 0 .....401th
10 11 1 1 -9.6 1 0 .....401th
............................
10 11 1 1 10 1 0 .....401th

And soon, until end date of month

thus, they are daily-hourly data in latitude and longitude space in a month. I want to accumulate this data into monthly-hourly latitude and longitude space. Data of the same hour will be added to the same hour data with the same lat and longitude. Final result will be 24 hour latitude and longitude space data, each hour accumulated data having their own file/output file. Now I try the following way to do it:

%input file assumed as dat_lon

Hour = 0:1:23;

for ii=1:1:24
    
cal1 =find(ismember(dat_lon(:,4),Hour(ii),'rows'));
data1=dat_lon(cal1,:);

minMon =min(data1(:,3)); %searh min date
maxMon =max(data1(:,3)); %searh max date

allMon = minMon:1:maxMon;
 data2i = repmat(0,[101 406]);
 for ik=1:1:length(allMon)
 cal2 =find(ismember(data1(:,3),allMon(ik),'rows'));
 data2=data1(cal2,:);
 data2i = data2i+data2;
 end
%dlmwrite(..) % write the data of current hour to output file
data2i = repmat(0,[101 406]);
end

Are there any more efficient way to do this job ? Thanks for your sharing...

Edward
                      

Subject: More efficient way to accumulate the data

From: Rune Allnor

Date: 15 Dec, 2011 05:35:49

Message: 2 of 4

On 15 Des, 06:28, "edward kabanyas" <djuky_...@yahoo.com> wrote:
> Hi All;
>
> I have a monthly data, with the structure as:
>
> year  month date hour  latitude data (401 coulumn)
> 10      11      1       0       -10  1   1 .....401th
> 10      11      1       0       -9.8 0   0 .....401th
> 10      11      1       0       -9.6 1   0 .....401th
> ............................
> 10      11      1       0        10  1   0 .....401th
> 10      11      1       1       -10  1   1 .....401th
> 10      11      1       1       -9.8 0   0 .....401th
> 10      11      1       1       -9.6 1   0 .....401th
> ............................
> 10      11      1       1        10  1   0 .....401th
>
> And soon, until end date of month
>
> thus, they are daily-hourly data in latitude and longitude space in a month. I want to accumulate this data into  monthly-hourly latitude and longitude space. Data of the same hour will be added to the same hour data with the same lat and longitude. Final result will be 24 hour latitude and longitude space data, each hour accumulated data having their own file/output file. Now I try the following way to do it:
>
> %input file assumed as dat_lon
>
> Hour = 0:1:23;
>
> for ii=1:1:24
>
> cal1 =find(ismember(dat_lon(:,4),Hour(ii),'rows'));
> data1=dat_lon(cal1,:);
>
> minMon =min(data1(:,3)); %searh min date
> maxMon =max(data1(:,3)); %searh max date
>
> allMon = minMon:1:maxMon;
>  data2i = repmat(0,[101 406]);
>  for ik=1:1:length(allMon)
>  cal2 =find(ismember(data1(:,3),allMon(ik),'rows'));
>  data2=data1(cal2,:);
>  data2i = data2i+data2;
>  end
> %dlmwrite(..)   % write the data of current hour to output file
> data2i = repmat(0,[101 406]);
> end
>
> Are there any more efficient way to do this job ? Thanks for your sharing...

Depends on what you mean by 'efficient'. I'd doubdt it
can be done in less code than what you already have,
but I wouldn't be surprised if run-time can be
significantly reduced. But that would require some
rather intense programming, which you may or may
not be prepared or motivated for.

Rune

Subject: More efficient way to accumulate the data

From: edward kabanyas

Date: 15 Dec, 2011 05:46:08

Message: 3 of 4

Hi rune,

thank you..You see I use two looping there, if possibe I need to avoid the looping procedure..

Edward

Rune Allnor <allnor@tele.ntnu.no> wrote in message <f4aaaf2d-3bce-4d22-a358-2c46a274b195@x7g2000yqb.googlegroups.com>...
> On 15 Des, 06:28, "edward kabanyas" <djuky_...@yahoo.com> wrote:
> > Hi All;
> >
> > I have a monthly data, with the structure as:
> >
> > year  month date hour  latitude data (401 coulumn)
> > 10      11      1       0       -10  1   1 .....401th
> > 10      11      1       0       -9.8 0   0 .....401th
> > 10      11      1       0       -9.6 1   0 .....401th
> > ............................
> > 10      11      1       0        10  1   0 .....401th
> > 10      11      1       1       -10  1   1 .....401th
> > 10      11      1       1       -9.8 0   0 .....401th
> > 10      11      1       1       -9.6 1   0 .....401th
> > ............................
> > 10      11      1       1        10  1   0 .....401th
> >
> > And soon, until end date of month
> >
> > thus, they are daily-hourly data in latitude and longitude space in a month. I want to accumulate this data into  monthly-hourly latitude and longitude space. Data of the same hour will be added to the same hour data with the same lat and longitude. Final result will be 24 hour latitude and longitude space data, each hour accumulated data having their own file/output file. Now I try the following way to do it:
> >
> > %input file assumed as dat_lon
> >
> > Hour = 0:1:23;
> >
> > for ii=1:1:24
> >
> > cal1 =find(ismember(dat_lon(:,4),Hour(ii),'rows'));
> > data1=dat_lon(cal1,:);
> >
> > minMon =min(data1(:,3)); %searh min date
> > maxMon =max(data1(:,3)); %searh max date
> >
> > allMon = minMon:1:maxMon;
> >  data2i = repmat(0,[101 406]);
> >  for ik=1:1:length(allMon)
> >  cal2 =find(ismember(data1(:,3),allMon(ik),'rows'));
> >  data2=data1(cal2,:);
> >  data2i = data2i+data2;
> >  end
> > %dlmwrite(..)   % write the data of current hour to output file
> > data2i = repmat(0,[101 406]);
> > end
> >
> > Are there any more efficient way to do this job ? Thanks for your sharing...
>
> Depends on what you mean by 'efficient'. I'd doubdt it
> can be done in less code than what you already have,
> but I wouldn't be surprised if run-time can be
> significantly reduced. But that would require some
> rather intense programming, which you may or may
> not be prepared or motivated for.
>
> Rune

Subject: More efficient way to accumulate the data

From: Bruno Luong

Date: 15 Dec, 2011 08:19:08

Message: 4 of 4

"edward kabanyas" <djuky_hmi@yahoo.com> wrote in message <jcc1j0$6f2$1@newscl01ah.mathworks.com>...
> Hi rune,
>
> thank you..You see I use two looping there, if possibe I need to avoid the looping procedure..

Please take a look at function ACCUMARRAY it does just that. Look also in the archive for examples.

Bruno

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us