-
Notifications
You must be signed in to change notification settings - Fork 3
/
circlePlot.m
52 lines (42 loc) · 1.27 KB
/
circlePlot.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Matlab function to plot 3 vectors as a circular plot using griddata
%
%% © R.A.I. Bethlehem 2012
%
% Version History:
%
% Richard Bethlehem
% 02-09-2012: Created basic structure & experimented with pcolor functionality for plotting
% 04-09-2012: Implemented meshrgid to create a circular and griddata to fit
% the data to this grid
function [] = CircularPlot(x,y,z,colour)
% check the input and restore to defaults if there is a mistake
if isempty(colour), colour = 'Gray', end;
if isempty(colour), fprintf('You have not entered a colour, default is greyscale\n'), end;
% transpose all matrices
x = x';
y = y';
z = z';
%% Plotting a circular grid:
% % input is 3 vectors
% x = angle; % in radials
% y = radius; % in radials
% z = strength; % how bright do you want it?
linespacing = length(x);
%% Create a circular grid
[r, theta] = meshgrid(0:.1:1, linspace(0,2*pi,linespacing));
% create the cartesian coordinates for this grid
[x2, y2] = pol2cart(theta, r);
%% Fit the data to the circular grid
z2 = griddata(x,y,z,x2,y2);
%% Plot it
figure;
subplot(2,1,1);
scatter(x,y,50,z, 'filled');
axis equal tight;
subplot(2,1,2);
pcolor(x2,y2,z2);
shading flat;
colormap(colour);
axis equal tight;
end