4 views (last 30 days)

John D'Errico
on 26 Mar 2020

Edited: John D'Errico
on 26 Mar 2020

You could at least spell my name right, since you had it right in front of you.

Regardless, it turns out that you changed your question, wanting to do something completely different from a contour plot in polar coordiantees. (The original question was indeed about contour plots.)

You have polar form data, so as a function of angle (here, wind direction), you have a parameter called FETCH2.

Now you are asking how to create the envelope of that data in polar form. That is simply the local maximum for FETCH2, as a function of angle. I would show how to do it, except that your data is not what you plotted. In fact, the data is quite different from what your picture shows.

However, the answer will still be the same. I would simply estimate the maximal value of FETCH2 as a function of angle. Don't do that using a set of TESTS for each angular bin!!!!!!!

In fact though, your data is NOT what you show it to be. It is NOT a nice uniform thing in polar coordiantes. In fact, you have very little data between some angles.

The problem is you used polarscatter INCORRECTLY!!!!!!!!!!

Read the help! Polarscatter and polarplot both assume the angle is in radians, NOT in degrees.

Here is your data, plotted now correctly in terms of RADIANS, when converted from degrees.

polarscatter(WD1*pi/180,FETCH2)

hist(WD1,50)

So you have essentially no data measured between roughly 120 degrees and 180 degrees.

Polarscatter does not automatically infer that the data looks like it is scaled to be degrees, so use it as degrees. It should never try to be that intelligent, because you might not want that to be done. In fact, the documentation for those tools explicitly states you need to provide angular information in terms of degrees, NOT radians.

You might ask why it is that polarplot indicates the angles as degrees on the plot, when it really wants radians as input, but that would be a valid question for the person who wrote the code. It sort of makes some sense, since we usually think of a polar plot in terms of degrees, so it labels the plot in degrees. The documentation should be wildly more clear about the presumption of radians as input however. Not my problem though.

Finally, there is the problem of how to generate that envelope. Remember that you have essentially no data for wide expanses of polar angle. This is more difficult, since you have so little data for much of the polar plot. It arguably makes very little sense to try to determine what is the maximum of that relationship near 150 degrees, since you have absolutely no data in that vicinity.

John D'Errico
on 1 Apr 2020

I cannot estimate it, as you have no data even remotely in the vicinity. Did you delete your data? It looks like you did, but luckily my history in MATLAB allowed me to recover it.

plot(WD1,FETCH2,'.')

As I said, you have no data in the region between 120 and 180 for WD1. So, is the maximum in that region as low as the roughly 2 data points in that region? Or would you choose to pick some arbitrary higher value?

The best way to solve your problem is logically to get better data, rather than making up a number.

An alternative might be to find the maximum value of FETCH2, as a function of angle within some tolerance in angle, perhaps +/- 15 degrees. The problem is, this may leave some regions with no data at all. What is the largest hole where we find no data at all?

max(diff(sort(WD1)))

ans =

27.128

So there is one interval where no data at all is seen over a 27 degree angular span. A +/- 15 degree window (thus a window of width 30 degrees) would then be just large enough that there would always be at least one data point in any interval.

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
## 2 Comments

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/513045-making-contours-in-polar-plot#comment_815598

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/513045-making-contours-in-polar-plot#comment_815598

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/513045-making-contours-in-polar-plot#comment_815607

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/513045-making-contours-in-polar-plot#comment_815607

Sign in to comment.