Color from surf and colorbar doesn't match

6 次查看(过去 30 天)
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

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by