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:
How to make data outside an irregular circle NaN?

Subject: How to make data outside an irregular circle NaN?

From: Li

Date: 26 Jun, 2010 14:38:04

Message: 1 of 4

I am trying to plot a figure to show the spatial distribution of A in the North Sea. have a three-column data set [Longitude, Latitude, A], which are generated from 'contour'. I also have a digitized two-column data of longitude and latitude to specify the circle outside which, I want my data to be set NaN, so that I do not need to plot data on land.

My question is how to set data outside the irregular circle NaN?

Thanks.

Subject: How to make data outside an irregular circle NaN?

From: Faraz Afzal

Date: 26 Jun, 2010 15:38:05

Message: 2 of 4

Hey Li,

As I understood you have one data in say Matrix B such as
B = [Longitude, Latitude, A]
and You have another matrix defining circle boundary say that is matrix C
C = [Long, Lat];
And you would liek the data outside this matrix C be NaN

If this is the case you gotta put condition with Matrix C such as:

if Long_Data <= C(:,1)
plot (whatever u want to plot)
elseif Long_Data > C(:,1)
Define here for the data as Nan
end
I hope it helps...

Regards,
Faraz

"Li " <liqingjiang@gmail.com> wrote in message <i053cc$m60$1@fred.mathworks.com>...
> I am trying to plot a figure to show the spatial distribution of A in the North Sea. have a three-column data set [Longitude, Latitude, A], which are generated from 'contour'. I also have a digitized two-column data of longitude and latitude to specify the circle outside which, I want my data to be set NaN, so that I do not need to plot data on land.
>
> My question is how to set data outside the irregular circle NaN?
>
> Thanks.

Subject: How to make data outside an irregular circle NaN?

From: Li

Date: 26 Jun, 2010 22:26:07

Message: 3 of 4

Hi Faraz,

Thank you for the reply. Yes, your understanding is correct.

I tried your method. It works great when the situation is simplified (for example just between two lines, but I am afraid it will not work for very complicated irregular circules, like those in a map (with bays, lagoons, peninsulas, etc).

If Matlab has the ability to fill the circle (use the function 'fill' ), there should be a way to get around this.

"Faraz Afzal" <farazafzal@gmail.com> wrote in message <i056st$6ar$1@fred.mathworks.com>...
> Hey Li,
>
> As I understood you have one data in say Matrix B such as
> B = [Longitude, Latitude, A]
> and You have another matrix defining circle boundary say that is matrix C
> C = [Long, Lat];
> And you would like the data outside this matrix C be NaN
>
> If this is the case you gotta put condition with Matrix C such as:
>
> if Long_Data <= C(:,1)
> plot (whatever u want to plot)
> elseif Long_Data > C(:,1)
> Define here for the data as Nan
> end
> I hope it helps...
>
> Regards,
> Faraz
>
> "Li " <liqingjiang@gmail.com> wrote in message <i053cc$m60$1@fred.mathworks.com>...
> > I am trying to plot a figure to show the spatial distribution of A in the North Sea. have a three-column data set [Longitude, Latitude, A], which are generated from 'contour'. I also have a digitized two-column data of longitude and latitude to specify the circle outside which, I want my data to be set NaN, so that I do not need to plot data on land.
> >
> > My question is how to set data outside the irregular circle NaN?
> >
> > Thanks.

Subject: How to make data outside an irregular circle NaN?

From: Faraz Afzal

Date: 26 Jun, 2010 23:20:20

Message: 4 of 4

Hi Li
Hmm....

I see...
So data is like irregular and complex stuff.. !!! Really I think i do need to understand your problem a little more and may be i can help.. For the time being according to my understanding I would suggest to use "intersect" of [Longitude,Latitude] with [long_data, Lat_data] and u will come to know the indices of the points that are of ur interestt..., You can then plot the data for these intersected indices..
may be what i m saying is menaingless, but it is just lack of understanding of the problem..
explain me a little bit more with an example and then we can work out on ur problem..I hope it helps. May be that Intersect if of some use to u..Try that..

Regards,
Faraz

 

"Li " <liqingjiang@gmail.com> wrote in message <i05upu$ln9$1@fred.mathworks.com>...
> Hi Faraz,
>
> Thank you for the reply. Yes, your understanding is correct.
>
> I tried your method. It works great when the situation is simplified (for example just between two lines, but I am afraid it will not work for very complicated irregular circules, like those in a map (with bays, lagoons, peninsulas, etc).
>
> If Matlab has the ability to fill the circle (use the function 'fill' ), there should be a way to get around this.
>
> "Faraz Afzal" <farazafzal@gmail.com> wrote in message <i056st$6ar$1@fred.mathworks.com>...
> > Hey Li,
> >
> > As I understood you have one data in say Matrix B such as
> > B = [Longitude, Latitude, A]
> > and You have another matrix defining circle boundary say that is matrix C
> > C = [Long, Lat];
> > And you would like the data outside this matrix C be NaN
> >
> > If this is the case you gotta put condition with Matrix C such as:
> >
> > if Long_Data <= C(:,1)
> > plot (whatever u want to plot)
> > elseif Long_Data > C(:,1)
> > Define here for the data as Nan
> > end
> > I hope it helps...
> >
> > Regards,
> > Faraz
> >
> > "Li " <liqingjiang@gmail.com> wrote in message <i053cc$m60$1@fred.mathworks.com>...
> > > I am trying to plot a figure to show the spatial distribution of A in the North Sea. have a three-column data set [Longitude, Latitude, A], which are generated from 'contour'. I also have a digitized two-column data of longitude and latitude to specify the circle outside which, I want my data to be set NaN, so that I do not need to plot data on land.
> > >
> > > My question is how to set data outside the irregular circle NaN?
> > >
> > > Thanks.

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