如何在matlab中更改球体的颜色我的绘图球体的代码是
figure;
plotOnSphere(Xem,Yem,Zem);
%// Plot a unit sphere for reference
sphere()
s = findall(gca, 'type', 'surf');
set(s, 'FaceColor', 'k', 'FaceAlpha', 0.01, 'EdgeAlpha', 0.1)
我的问题是,我想得到的球体图只有线条而不是这些颜色附在球形部分上。 有人可以帮助我。
function plotOnSphere(x,y,z,varargin)
%// Vectors representing each point
xyz = [x(:), y(:), z(:)].'; %'
%// One vector of the "first" points and one of the "next" points
v1 = xyz(:, 1:end-1);
v2 = xyz(:, 2:end);
%// Cross product between the vectors of one point and the next
cv1v2 = cross(v1, v2);
%// Compute unit vector in the plane defined by v1 and v2
v3 = normc(cross(cv1v2, v1));
%// Figure out the range of the inner angle between v1 and v2
nc = sqrt(sum(cv1v2.^2, 1));
t = atan2(nc, dot(v1, v2, 1));
%// Number of points to sample between any two points on the sphere
nPoints = 100;
%// Compute the interpolant
V = zeros([nPoints, fliplr(size(v1))]);
for k = 1:numel(t)
T = linspace(0, t(k), 100);
V(:,k,:) = (v1(:,k) * cos(T) + v3(:,k) * sin(T)).'; %'
end
%// Break the result out into x,y,z parts
xx = V(:,:,1);
yy = V(:,:,2);
zz = V(:,:,3);
%// Plot the lines
h = plot3(xx(:), yy(:), zz(:), varargin{:});
hold on
%// Plot the original data points
plot3(x,y,z, 'o', ...
'Color', get(h, 'Color'), ...
'Parent', get(h, 'Parent'), varargin{:});
end