Color from surf and colorbar doesn't match

2 views (last 30 days)
An Zou
An Zou on 28 Jun 2017
Answered: Star Strider on 28 Jun 2017
I am using 'surf' to create a 3D surface plot. However, the color in the plot does not match what is shown in color bar. Here is the code, please help.
if true
r = (1:0.01:3);
m = length(r);
theta = linspace(0,2*pi,721);
n = length(theta);
for i=1:m
for j=1:n
x(i,j) = r(i)*cos(theta(j));
y(i,j) = r(i)*sin(theta(j));
z(i,j) = r(i)^2;
end
end
surf(x,y,z)
colorbar
end

Answers (1)

Star Strider
Star Strider on 28 Jun 2017
The color does match when I run it in R2017a, and use mesh instead of surf to do the plot.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!