Thread Subject: resizing database

Subject: resizing database

From: Fiona Buckley

Date: 9 Feb, 2009 14:14:01

Message: 1 of 3

Could someone please help me out...

I have a very large database and according to certain critirias I'm only selecting a part of it and renaming it in order to do my calculations faster.
So for example I have a database of 30200x200 where one of the columns represents time. Through a for and an if loop I have a new database of 500x200 (say only looking at half a day's data if a series of criterias are fullfilled).

My problem is that when doing this, my new database of 500x200 has a series of rows with zeros values (created by the if and for loops - these were not there beforehand). In reality my actual data is 350x200.
To remove the zeros I have another loop. However, as I have to repeat this several times, this takes a while to compute.

Is there anyway I can speed the process up?

Cheers

Subject: resizing database

From: Christopher Hummersone

Date: 9 Feb, 2009 14:37:02

Message: 2 of 3

It might help if you posted some code... :-)

Subject: resizing database

From: Fiona Buckley

Date: 9 Feb, 2009 15:04:01

Message: 3 of 3

Sorry thought it would be easier with words. Anyway, here goes...

The script starts by seperating data into days and then runs if certain conditions are fullfilled (I.E. if the data has a full days worth of info - stating at measurement 1 and finishing at measurement 8640)

for v=1:((length(Loc))-1);
if A((Loc(v,1)),2)==1
if A((Loc(v+1,1))-1,2)==8640

% seperating the database into smaller ones
            for m=1:2975
                for n=1:200
                    if A(m,39)==1
                        Cloudy(m,n)=A(m,n);
                    elseif A(m,39)==2
                        Rainy(m,n)=A(m,n);
                     elseif A(m,39)==3
                        Sunny(m,n)=A(m,n);
                     end
                end
            end

% removing the zeros
s=size(Day1);
Down=s(1,1);
Across=s(1,2);
           for m=1:Down
               for n=1:Across
                   if Day1(m,1)~= 0
                       Day1(m,n)=Day1(m,n);
                   else
                       Day1(m,n)=NaN;
                   end
               end
           end
           Day1(any(isnan(Day1),2),:) = [];
%This is obviously repeated for every smaller database

.... % remaning of calculations to be done
end
end


I hope this makes things clearer...

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com