簡體   English   中英

MATLAB:向3D圖添加一條線

[英]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)

這使:

3dplot

我想要的是沿着x軸整個長度的平面延伸的黑線。

任何建議將不勝感激。 謝謝!

我認為這只是范圍問題。 這似乎工作得很好:

   threshAccel = [97 97.0870 104.4212 109.5787]
    threshFreq = [0 50 100 500]

但我不確定970是否為精確值。 您應該更正它們。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM