Wednesday, February 07, 2007

Chateau de Pierrefonds Update

As a follow-up to my earlier post, my mom just sent me this month's newsletter from France Monthly. It provides a nice history of the Castle of Pierrefonds and is worth the read.

Now that I know so much more about the castle, it would be nice to go back and see it.

Tuesday, January 02, 2007

Improving pcolor with hullfit

Hi everyone,

Found a great new function today.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=6243

I was looking for something that could quickly make an outline from a mess of points, specifically a quick way to create a polygon shape to use with fill function to show the outline of a radial site's coverage area. Passing the complete array of locations results in a funky 80's Escher-like motif that's not at all pretty.

Anyway, as it turns out, the built-in "convhul" function does this, but it's goal is to minimize the circumference of the polygon whereas "hullfit" minimizes the polygon's area.

Why is this so noteworthy? Well, meshgrid and pcolor (among other functions) use convhul, and as we know they do a lousy job of showing data in areas that don't really exist. (That bend in NJ around Tuckerton is especially annoying, as is Sandy Hook since both tend to result in Codar data appearing on land.)

Well, the comments in "hullfit" showcases its true usefulness. I repeat some snippets from the simple example here...

xi=linspace(min(x),max(x),100);
yi=linspace(min(y),max(y),100);
zi=griddata(x,y,z,xi,yi');
k=hullfit(x,y,0.1);
[xx,yy]=meshgrid(xi,yi);
in=inpolygon(xx,yy,x(k),y(k));
zi(~in)=NaN;
pcolor(xi,yi,zi),shading interp

This far surpasses the alternative way I had developed a few months ago using the mapping toolbox's distance function and an arbitrary distance threshold between points.

And, better yet, I also (re)discovered another cool function called "inpolygon" which is sure to be of future use.

The year is already starting well. Enjoy!