Thread Subject:
Griding data

Subject: Griding data

From: Shaik Ghouse Basha

Date: 4 Apr, 2012 03:14:15

Message: 1 of 5

Dear Friends, I am facing problem in Griding data in matlab. I have written the code but its taking sooo much time to process. My data contains X(longitude) Y(latitude) Z(data points) with 0.5 degree resolution. I have to make this data gridding with 1.5x1.5 degree resolution. please help me how to save the time and also i have gone through all the griding programs in mathworks.com.

Subject: Griding data

From: Nasser M. Abbasi

Date: 4 Apr, 2012 03:32:49

Message: 2 of 5

On 4/3/2012 10:14 PM, Shaik Ghouse Basha wrote:
> Dear Friends, I am facing problem in Griding data in matlab.
>I have written the code but its taking sooo much time to process.
>My data contains X(longitude) Y(latitude) Z(data points) with 0.5 degree
>resolution. I have to make this data gridding with 1.5x1.5 degree
> resolution. please help me how to save the time and also i have gone
>through all the griding programs in mathworks.com.

It will help others help you more by making small example
of the problem, post the complete code of the small example
here.

Hard to help you without seeing anything.

--Nasser

Subject: Griding data

From: Shaik Ghouse Basha

Date: 4 Apr, 2012 03:51:26

Message: 3 of 5

I have X Y Z of length 13000 like this i have 16700 columns of data
for j=1
eps1=1.5;
        Eda=nan(length(lat1),length(lon1));
        for k=1:length(Z)
            
            P1=find(lat1>=Y(k)-eps1 & lat1<=Y(k)+eps1);
            Q1=find(lon1>=X(k)-eps1 & lon1<=X(k)+eps1);
            if length(P1)>1
                P1=P1(1);
            end
            if length(Q1)>1
                Q1=Q1(1);
            end
            
            Eda(P1,Q1)=nanmean([Eda(P1,Q1) Z(k)]);
        end
end

"Nasser M. Abbasi" <nma@12000.org> wrote in message <jlgfdf$ujr$2@speranza.aioe.org>...
> On 4/3/2012 10:14 PM, Shaik Ghouse Basha wrote:
> > Dear Friends, I am facing problem in Griding data in matlab.
> >I have written the code but its taking sooo much time to process.
> >My data contains X(longitude) Y(latitude) Z(data points) with 0.5 degree
> >resolution. I have to make this data gridding with 1.5x1.5 degree
> > resolution. please help me how to save the time and also i have gone
> >through all the griding programs in mathworks.com.
>
> It will help others help you more by making small example
> of the problem, post the complete code of the small example
> here.
>
> Hard to help you without seeing anything.
>
> --Nasser
>

Subject: Griding data

From: Andrew Stevens

Date: 4 Apr, 2012 14:06:09

Message: 4 of 5

"Shaik Ghouse Basha" wrote in message <jlggfu$1ua$1@newscl01ah.mathworks.com>...
> I have X Y Z of length 13000 like this i have 16700 columns of data
> for j=1
> eps1=1.5;
> Eda=nan(length(lat1),length(lon1));
> for k=1:length(Z)
>
> P1=find(lat1>=Y(k)-eps1 & lat1<=Y(k)+eps1);
> Q1=find(lon1>=X(k)-eps1 & lon1<=X(k)+eps1);
> if length(P1)>1
> P1=P1(1);
> end
> if length(Q1)>1
> Q1=Q1(1);
> end
>
> Eda(P1,Q1)=nanmean([Eda(P1,Q1) Z(k)]);
> end
> end
>
> "Nasser M. Abbasi" <nma@12000.org> wrote in message <jlgfdf$ujr$2@speranza.aioe.org>...
> > On 4/3/2012 10:14 PM, Shaik Ghouse Basha wrote:
> > > Dear Friends, I am facing problem in Griding data in matlab.
> > >I have written the code but its taking sooo much time to process.
> > >My data contains X(longitude) Y(latitude) Z(data points) with 0.5 degree
> > >resolution. I have to make this data gridding with 1.5x1.5 degree
> > > resolution. please help me how to save the time and also i have gone
> > >through all the griding programs in mathworks.com.
> >
> > It will help others help you more by making small example
> > of the problem, post the complete code of the small example
> > here.
> >
> > Hard to help you without seeing anything.
> >
> > --Nasser
> >

you might find this function useful:

http://www.mathworks.com/matlabcentral/fileexchange/23479-bin2mat

It is not optimized for speed, but may be faster than your current code.
-Andrew

Subject: Griding data

From: TideMan

Date: 4 Apr, 2012 04:39:03

Message: 5 of 5

On Wednesday, April 4, 2012 3:51:26 PM UTC+12, Shaik Ghouse Basha wrote:
> I have X Y Z of length 13000 like this i have 16700 columns of data
> for j=1
> eps1=1.5;
> Eda=nan(length(lat1),length(lon1));
> for k=1:length(Z)
>
> P1=find(lat1>=Y(k)-eps1 & lat1<=Y(k)+eps1);
> Q1=find(lon1>=X(k)-eps1 & lon1<=X(k)+eps1);
> if length(P1)>1
> P1=P1(1);
> end
> if length(Q1)>1
> Q1=Q1(1);
> end
>
> Eda(P1,Q1)=nanmean([Eda(P1,Q1) Z(k)]);
> end
> end
>
> "Nasser M. Abbasi" <nma@12000.org> wrote in message <jlgfdf$ujr$2@speranza.aioe.org>...
> > On 4/3/2012 10:14 PM, Shaik Ghouse Basha wrote:
> > > Dear Friends, I am facing problem in Griding data in matlab.
> > >I have written the code but its taking sooo much time to process.
> > >My data contains X(longitude) Y(latitude) Z(data points) with 0.5 degree
> > >resolution. I have to make this data gridding with 1.5x1.5 degree
> > > resolution. please help me how to save the time and also i have gone
> > >through all the griding programs in mathworks.com.
> >
> > It will help others help you more by making small example
> > of the problem, post the complete code of the small example
> > here.
> >
> > Hard to help you without seeing anything.
> >
> > --Nasser
> >

Well, I can see why it's taking so long.
It's those find commands.
They assume your data are randomly distributed, but actually they're in a grid aren't they?
In which case, you can reshape the vectors into matrices and apply a bit of intelligence to how you process the data.
What are the dimensions of your grid?

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