File Exchange Pick of the Week

Our best user submissions

3D Polar Plotting

Brett's Pick this week is polarplot3d, by Ken Garrard.

I don't often get suggestions from readers of this blog for which files to feature. Typically, I just focus on files that I've found, or that look useful or intriguing based on descriptions and comments. This week is different; I received an email from long-time MATLABber Yair Altman, suggesting that I consider Ken's file as a Pick of the Week. Yair is one of the most downloaded authors on the MATLAB Central File Exchange (and is recognized as an expert in "undocumented MATLAB.") So I was quite pleased to see his recommendation come in, and happier still to be able to feature it.

Ken's code allows you to easily plot a 3D surface from polar coordinate data. With an easy-to-use syntax, his code supports the creation of several standard (and some custom) plot types, including surface plots (with and without lines, and with and without contours) and mesh plots (with and without contours). You can also specify lots of different parameters, including the polar direction (cw or ccw), the type of interpolation, and the color scheme. Optional outputs readily provide the Cartesian locations corresponding to input polar coordinates (T,R,Zp). To illustrate, here is Ken's own example from his code:

[t,r] = meshgrid(linspace(0,2*pi,361),linspace(-4,4,101));
[x,y] = pol2cart(t,r);
P = peaks(x,y);                       % peaks function on a polar grid

figure('color','white');              % draw 3d polar plot
polarplot3d(P,'PlotType','surfn','PolarGrid',{4 24},'TickSpacing',8,...
    'AngularRange',[30 270]*pi/180,'RadialRange',[.8 4]);

% set plot attributes
set(gca,'DataAspectRatio',[1 1 10],'View',[-12,38],...
    'Xlim',[-4.5 4.5],'Xtick',[-4 -2 0 2 4],...
    'Ylim',[-4.5 4.5],'Ytick',[-4 -2 0 2 4]);
title('polarplot3d example');

As always, comments to this blog post are welcome. Or leave a comment for Ken here. And if you have any suggestions for files (other than your own, please) that you think should be considered as a future Pick of the Week, please email me! I can be reached directly at:

char(cumsum(...
    [98 16 -13 15 0 -70 69 -11 7 -10 7 7 -4 -1 ...
    -46 45 -12 19 -12 15 -8 3 -7 8 -69 53 12 -2]));




Published with MATLAB® 7.13

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.