-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolarplot3d_try.m
90 lines (74 loc) · 2.99 KB
/
polarplot3d_try.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
clc
clear all
close all
%% Examples of the polarplot3d function
% The peaks function on a polar grid
[t,r] = meshgrid(linspace(0,2*pi,361),linspace(-4,4,101));
[x,y] = pol2cart(t,r);
P = peaks(x,y);
% Define some angular and radial range vectors for example plots
t1 = 2*pi;
t2 = [0 360]*pi/180;
r1 = 4;
r2 = [.8 4];
t3 = fliplr(t2);
r3 = fliplr(r2);
t4 = [30 35 45 60 90 135 200 270]*pi/180;
r4 = [0.8:0.4:2.8 3:0.2:4];
% Axis property cell array
axprop = {'DataAspectRatio',[1 1 8],'View', [-12 38],...
'Xlim', [-4.5 4.5], 'Ylim', [-4.5 4.5],...
'XTick',[-4 -2 0 2 4], 'YTick',[-4 -2 0 2 4]};
%% Plot using default arguments
figure('Name','1','color','white');
polarplot3d(P);
view([-18 76]);
% view(2)
%% Plot of an incomplete polar annulus, color is azimuthal gradient
figure('Name','2','color','white');
polarplot3d(P,'plottype','surf','angularrange',t2,'radialrange',r2,...
'polargrid',{1 16},'tickspacing',8,'colordata',gradient(P),...
'plotprops',{'Linestyle','none'});
set(gca,axprop{:});
%% Surface plot with contours
figure('Name','3','color','white');
polarplot3d(P,'plottype','surfcn','angularrange',t2,'radialrange',r2,...
'polargrid',{10 24},'tickspacing',15);
set(gca,axprop{:});
%% Surface plot with unequally spaced polar grid lines
figure('Name','4','color','white');
polarplot3d(P,'plottype','surfn','radialrange',[min(r4) max(r4)],...
'angularrange',[min(t4) max(t4)],'polargrid',{r4 t4},'tickspacing',15);
set(gca,axprop{:});
%% Surface plot, compass convention, color is radial direction gradient
figure('Name','5','color','white');
polarplot3d(P,'plottype','surfn','angularrange',t2,...
'radialrange',r2,'tickspacing',15,...
'polardirection','cw','colordata',gradient(P.').');
set(gca,axprop{:});
%% Mesh plot with polar axis at mean value, reversed angular sense
figure('Name','6','color','white');
polarplot3d(P,'plottype','mesh','angularrange',t3,'radialrange',r2,...
'meshscale',2,'polargrid',{1 1},'axislocation','mean');
set(gca,axprop{:});
%% Mesh plot with polar axis along edge of surface
figure('Name','7','color','white');
polarplot3d(P,'plottype','mesh','angularrange',t2,'radialrange',r2,...
'polargrid',{10 24},'tickspacing',8,...
'plotprops',{'Linestyle','none'});
set(gca,axprop{:});
%% Mesh plot with contours, overlay 8 by 8 polar grid
figure('Name','8','color','white');
polarplot3d(P,'plottype','meshc','angularrange',t2,'radialrange',r3,...
'meshscale',2,'polargrid',{8 8});
set(gca,axprop{:});
%% Wireframe plot
figure('Name','9','color','white');
polarplot3d(P,'plottype','wire','angularrange',t2,'radialrange',r2,...
'polargrid',{24 24});
set(gca,axprop{:});
%% Surface and contour plot, reversed radial sense
cl = round(min(P(:))-1):0.4:round(max(P(:))+1);
figure('Name','10','color','white');
polarplot3d(P,'plottype','contour','polargrid',{6 4},'contourlines',cl);
set(gca,'dataaspectratio',[1 1 1],'view',[0 90]);