Matlab中的mArrow3函数行为怪异

Matlab中的mArrow3函数行为怪异,matlab,matlab-figure,figure,Matlab,Matlab Figure,Figure,如图所示,我使用mArrow3函数来显示平面的方向。 但是,有时任何飞镖的行为都很奇怪 我正在使用的代码: drawnow; xExt = abs(diff(get(gca, 'XLim'))); yExt = abs(diff(get(gca, 'YLim'))); zExt = abs(diff(get(gca, 'ZLim'))); mArrow3([0 0 0],[xExt / 1, 0, 0], 'lineWidth', 2,'color','red','facealpha', 0.

如图所示,我使用mArrow3函数来显示平面的方向。 但是,有时任何飞镖的行为都很奇怪

我正在使用的代码:

drawnow;
xExt = abs(diff(get(gca, 'XLim')));
yExt = abs(diff(get(gca, 'YLim')));
zExt = abs(diff(get(gca, 'ZLim')));
mArrow3([0 0 0],[xExt / 1, 0, 0], 'lineWidth', 2,'color','red','facealpha',  0.1);
mArrow3([0 0 0],[0, yExt / 1, 0], 'lineWidth',  2,'color','red','facealpha',0.1);
mArrow3([0 0 0],[0, 0, zExt / 1], 'lineWidth',  2,'color','red','facealpha',0.1);


text(xExt, 0, 0, 'Vx','FontSize',12);  
text(0, yExt, 0, 'Vy','FontSize',12); 
text(0, 0, zExt, 'Vz','FontSize',12);

关于这个问题,您能给我一些提示吗?

根据
mArrow3
()的内联文档,控制线条外观的三个属性是:

% properties: 'color':      color according to MATLAB specification
%                           (see MATLAB help item 'ColorSpec')
%             'stemWidth':  width of the line
%             'tipWidth':   width of the cone 
如您所见,
“线宽”
不是这些选项之一。要理解为什么会出现上述行为,可以查看函数定义,看看如果函数调用中没有传递这些值会发生什么:

%% default parameters
if ~exist('stemWidth','var')
    ax = axis;
    if numel(ax)==4
        stemWidth = norm(ax([2 4])-ax([1 3]))/300;
    elseif numel(ax)==6
        stemWidth = norm(ax([2 4 6])-ax([1 3 5]))/300;
    end
end
if ~exist('tipWidth','var')
    tipWidth = 3*stemWidth;
end
如您所见,如果未提供
stemWidth
tipWidth
mArrow3
分别基于轴限制和
stemWidth
标准化其值

那么为什么它不抛出一个错误呢?如果进一步查看函数定义,可以查看错误检查:

%% draw
fv.faces = f;
fv.vertices = v;
h = patch(fv);
for propno = 1:numel(propertyNames)
    try
        set(h,propertyNames{propno},propertyValues{propno});
    catch
        disp(lasterr)
    end
end

这样做的目的是对您传递的不是
'color'
'stemWidth'
'tipWidth'
的属性使用一个。如果它们不是对象的有效属性,
set
将抛出一个错误,捕获并显示该错误以防止函数完全出错。如果您签出,您将看到,因此
set
不会出错。但是,它控制面片边缘的宽度,我猜这不是您实际想要调整的属性。

“行为怪异”。。。我们还需要做更多的工作。什么是
mArrow3
?它是一个函数,可以显示飞机的方向。在本例中,红色箭头。我的意思是,正如你在图片中看到的,Vx的宽度不同于Vy和Vz。我不知道为什么,因为设置是一样的。这不是一个内置的功能。它在哪里?请参阅:使用stemWidth而不是lineWidth会使箭头消失,只显示文本。可能是因为
2
约为
0.08%
最小轴范围的大小。你需要将它们规格化为你的轴。效果更好,我使用了数字10而不是2,但它看起来是平面的,不是3D的,而且在所有情况下长度都不一样。有时,圆锥体只显示为合并,直线不显示。总之,它的行为并不总是相同的。如果轴不一致,则需要单独操作参数,或者提出一个提供所需视觉效果的规范化。