[英]MATLAB: add a line to 3D plot
我想在3d图上添加一条参考线,该参考线遵循用mesh()构建的表面。 我在x和y轴上有3个点来构建直线,因此需要进行插值以找到z轴坐标。 到目前为止,这是我的代码(具有可复制的数据):
acceleration_dB = [0 109.3699 118.0084 133.9584 104.3017 110.5423 120.6332 140.6567 144.4194 129.7292]';
frequency = [1 50 50 50 100 100 100 100 100 500]';
voltage = [ 1.0e-04 * 0.0001 0.0968 0.1645 0.2983 0.0278 0.0368 0.0893 0.2785 0.4928 0.0780 ]';
xlin=linspace(0, max(frequency),33);
ylin=linspace(min(acceleration_dB), max(acceleration_dB),33);
[X, Y] = meshgrid(xlin,ylin);
f = scatteredInterpolant(frequency,acceleration_dB,log(voltage));
Z=f(X,Y);
figure();
mesh(X,Y,Z);
hold on
% Add threshold reference line
threshAccel = [97.0870 104.4212 109.5787]
threshFreq = [50 100 500]
Zthresh=f(threshFreq,threshAccel);
plot3(threshFreq,threshAccel,Zthresh,'Color','black','LineWidth',1)
这使:
我想要的是沿着x轴整个长度的平面延伸的黑线。
任何建议将不胜感激。 谢谢!
我认为这只是范围问题。 这似乎工作得很好:
threshAccel = [97 97.0870 104.4212 109.5787]
threshFreq = [0 50 100 500]
但我不确定97
和0
是否为精确值。 您应该更正它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.