# Polar Contour not interpolating between values

2 views (last 30 days)
Benjamin Cowen on 24 Oct 2017
Edited: Benjamin Cowen on 24 Oct 2017
I have a function that I found online:
% POLARCONT Polar contourf plot
%
% Richard Rieber
% rrieber@gmail.com
% April 4, 2007
% Updated June 15, 2007
%
% function [C,h] = polarcont(r,theta,z,N,s)
%
% Purpose: This function creates polar contourf plots on the current active
% figure
%
% Inputs: o r - Radius vector of length m
% o theta - Angle vector in radians of length n
% o z - Magnitude at the points specified in r and theta of
% size m x n
% o N - The number of contourfs to plot [OPTIONAL]
% o s - Linespec as described in PLOT [OPTIONAL]
%
% Outputs: o C - returns contourf matrix C as described in contourfC
% o h - Column vector H of handles to LINE or PATCH objects,
% one handle per line.
%
% OTHER NOTES:
% - Both C and h can be used as inputs to CLABEL
% - Colors are defined in colormap
% - Treat this function as a standard contourf plot
function [C,h] = polarcont(r,theta,z,N,s)
[a,b] = size(z);
if a ~= length(r)
error('r is not the same length as the first dimension of z')
end
if b ~= length(theta)
error('theta is not the same length as the second dimension of z')
end
x = zeros(a,b);
y = zeros(a,b);
for j = 1:a
for k = 1:b
x(j,k) = r(j)*cos(theta(k));
y(j,k) = r(j)*sin(theta(k));
end
end
if nargin == 3
[C,h] = contourf(x,y,z);
elseif nargin == 4
[C,h] = contourf(x,y,z,N);
elseif nargin == 5
[C,h] = contourf(x,y,z,N,s);
else
error('Incorrect number of inputs')
end
However, I have a hard time getting the plot to look how I want. The colors do not interpolate between values, and if I increase the number (N) contours, I end up getting a lot of black lines all over my graph. Can someone take a look at my code below, and tell me if there is anything that I have that causes the colors to not interpolate between values? I hate the sharp transitions. Another option would be getting rid of all the black lines that appear if I choose 100 contours. I think I am missing something obvious.
close all
clear
clc
t1 = data1(1,:);
r1 = data2(:,1);
z1 = data3(:,:);
figure(1)
polarcont(r1,t1,z1,10);
myColorMap = colormap;
myColorMap(1,:) = [1 1 1];
colormap(myColorMap);
colorbar
caxis([0 10])
beta = 0.8;
brighten(beta);
plotting_circle(0,0,100);
plotting_circle(0,0,200);
plotting_circle(0,0,300);
plotting_circle(0,0,400);
axis equal
axis off
Those sharp transitions you see aren't real. There are plenty of color values of 3.9 and 4 that are colored the same as if they were 0 or 1 or 2. Figure is attached. How can I remove the isolines?