【问题标题】:Suppress opening a MATLAB figure禁止打开 MATLAB 图窗
【发布时间】:2019-12-10 09:23:06
【问题描述】:

如何防止 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)';

我希望计算 xryrzr,但不希望从此特定脚本创建任何图。我稍后想使用这些数据创建一个不同的图。如果还有其他方法可以做到这一点,请告诉我。

【问题讨论】:

  • 您正在创建绘图。您拥有专门且独特地创建绘图的代码。 surface 唯一的工作就是策划!您似乎在使用错误的工具来完成这项工作。这部分代码的目的是什么?您可以对数据应用几何变换和其他东西,而无需绘图。
  • 我是 MATLAB 新手,所以我对这些工具以及如何使用它们不是很熟悉。代码的目的是创建一个视场锥,从一个点指向原点。我想要圆锥的坐标。我通过沿 x 轴制作一个正确尺寸的圆锥体,然后将其旋转以与该点的原点向量对齐来获得它们。
  • 您旋转的是曲面图,而不是圆锥。您制作一个图,然后获取该图,然后旋转该图,并提取其新位置。你似乎有XY问题。你的实际问题是如何创建一个圆锥体并旋转它,而不是如何避免你尝试这样做。
  • 我明白了,谢谢。我会发布一个新问题。
  • 或者edit这个

标签: matlab plot matlab-figure


【解决方案1】:

正如Ander Biguri 已经说过的那样,可能有比将圆钉塞进方孔更好的方法。
至于问题本身:figure visibility 是通过figure('Visible', 'off') 控制的,其中'on' 显然是默认的。不过不要忘记关闭你的身影:

fig = figure('Visible', 'off'); % Create invisible figure with handle
h = surface(...); % Your plot
% (...) your other processing
close(fig); % Close figure to save RAM

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多