如何防止MATLAB绘制对象及其变换?我正在尝试旋转一个曲面,并使用转换矩阵来执行此操作,但我不希望在任何点绘制该曲面,如何停止它?
% Defines the input variables for the SC at the orbital point.
FoV = deg2rad(FoV);
dist = sqrt(xp^2 + yp^2 + zp^2);
xp = 168.820350140000;
yp = 22703.2636668300
zp = 40331.2908433900
% Generates a line from the orbit point to the centre of the Earth.
xl = linspace(0,xp);
yl = linspace(0,yp);
zl = linspace(0,zp);
% Plots the orbits, orbit point, and Earth object onto the same plot.
plot3(xl,yl,zl);
hold on
scatter3(xp,yp,zp,100,'x','blue')
% Creates a cone for the FoV of the SC that targets the Earth's centre.
[x,y,z] = cylinder([dist*tan(FoV) 0],100);
h = surface(y,dist*z,x);
t = hgtransform('Parent',ax);
set(h,'Parent',t);
x_temp = get(h,'xdata');y_temp = get(h,'ydata');z_temp = get(h,'zdata'); % Duplicates data.
% Determines the coordinate rotations needed to align the cone with the
% orbit point and transforms the cone using object R.
% This if loop calibrates the cone for the 4 quadrants of 2 tangents.
xa = atan(yp/xp);
za = atan(zp/sqrt(xp^2+yp^2));
if xp>0
xa = xa-pi/2;
else
xa = xa+pi/2;
end
R = makehgtform('zrotate',xa,'xrotate',za);
set(t,'Matrix',R);
% Performs the same numerical transformation of the duplicate data and
% creates a sew sets of coordinates that match the transformation.
for i = 1:101
new_first_row(i,:) = (R * [x_temp(1,i);y_temp(1,i);z_temp(1,i);1])';
new_second_row(i,:) = (R * [x_temp(2,i);y_temp(2,i);z_temp(2,i);1])';
end
xr = new_first_row(:,1)'; % Transformed x data.
xr(2,:) = new_second_row(:,1)';
yr = new_first_row(:,2)'; % Transformed y data.
yr(2,:) = new_second_row(:,2)';
zr = new_first_row(:,3)'; % Transformed z data.
zr(2,:) = new_second_row(:,3)';
我希望输出xr,yr和zr,但不希望从此特定脚本创建任何绘图。稍后,我想使用此数据创建其他图。如果还有其他方法,请告诉我。谢谢!
[Ander Biguri已经说过,可能有比将圆钉塞入方孔更好的方法。对于问题本身:图形可见性是通过figure('visibility', 'off')
控制的,其中'on'
显然是默认设置。不过不要忘了结束你的身影:
fig = figure('visibility', 'off'); % Create invisible figure with handle
h = surface(...); % Your plot
% (...) your other processing
close(fig); % Close figure to save RAM