2014-09-22 32 views
2

交叉我有如下繪製幾個數據點,我希望找到頻率值振幅值越過。我在下面的例子中包含了一個例子以及數據點。我以圖形方式圈出了答案,但我不確定如何在數學上進行計算,並獲得所需頻率的所有值。我如何用八度/ matlab做到這一點?對於我想要做的事情,還有一個數學術語?查找其中曲線可以與倍頻程/ MATLAB

在這個例子中,我試圖讓5個頻率(但這僅僅是一個例子),我知道兩個答案都是和但不知道如何得到休息。完整的列表可能是數千。 我用八度3.8.1

clear all,clf, clc,tic 
%graphics_toolkit gnuplot %use this for now it's older but allows zoom 
freq=[20,30,40,50,60,70,80]; 
amp_orig=[2,4,3,7,1,8,4]; 
amp_inv=[6,4,5,1,7,0,4]; 


plot(freq,amp_orig,'-bo') 
hold on 
plot(freq,amp_inv,'-r*') 
xlabel ("Frequency"); 
ylabel ("Amplitude"); 

enter image description here

感謝

+2

這有幫助嗎? http://www.mathworks.com/matlabcentral/fileexchange/27205-fast-line-segment-intersection – amo 2014-09-22 23:16:16

+0

要回答你的其他問題,你要做的是找到線的交集。 [這](http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect)問題給出了很好的概述各種技術。 – MrAzzaman 2014-09-22 23:35:56

+0

@amo謝謝,但這個功能不能用八度音3.8.1 – 2014-09-23 11:51:33

回答

1

嘗試從文件交換this function,似乎在八度的工作就好了。 x0是感興趣的頻率:

>> [x0,y0,iout,jout] = intersections(freq,amp_orig,freq,amp_inv) 
x0 = 

    30.000 
    30.000 
    42.500 
    55.000 
    64.286 
    80.000 

y0 = 

    4.0000 
    4.0000 
    4.0000 
    4.0000 
    4.0000 
    4.0000 

iout = 

    2.0000 
    2.0000 
    3.2500 
    4.5000 
    5.4286 
    7.0000 

jout = 

    2.0000 
    2.0000 
    3.2500 
    4.5000 
    5.4286 
    7.0000 
2

如果您有機會獲得Matlabs映射工具箱,你的問題可以很容易地使用功能polyxpoly()來解決。它會找到兩個圖的交點。它們甚至不必是線條,多邊形也可以工作。這裏是你的情況的一個例子:

%graphics_toolkit gnuplot %use this for now it's older but allows zoom 
freq=[20,30,40,50,60,70,80]; 
amp_orig=[2,4,3,7,1,8,4]; 
amp_inv=[6,4,5,1,7,0,4]; 

plot(freq,amp_orig,'-bo') 
hold on 
plot(freq,amp_inv,'-r*') 
xlabel ('Frequency'); 
ylabel ('Amplitude'); 

%// find and add intersections 
[xi,yi] = polyxpoly(freq,amp_orig,freq,amp_inv) 
plot(xi, yi,'ro','markersize',20) %// draw the red circles automatically :-) 

結果看起來是這樣的enter image description here

+1

謝謝,但我使用八度,它看起來像映射工具箱還沒有polyxpoly功能 – 2014-09-23 11:50:41

+0

@RickT對,''polyxpoly()' '是映射工具箱的一部分,我應該在答案中提到這一點。太糟糕了,這會讓你的問題變得很容易。 – Nras 2014-09-23 12:12:50