MATLAB:在3D绘图中添加一条线

时间:2016-06-06 04:47:29

标签: matlab plot 3d line

我想在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)

给出了:

3dplot

我想要的是沿x轴整个长度的表面平面后面的黑线。

任何建议都将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:1)

这只是我认为的范围问题。这看起来效果很好:

Intent intent = new Intent(this, typeof(SettingsActivity));
StartActivity(intent);

但我不确定 threshAccel = [97 97.0870 104.4212 109.5787] threshFreq = [0 50 100 500] 97是否为精确值。你应该纠正它们。