2016-12-16 5 views
-3

MATLABの信号(オーディオ信号)コードに対してFFTを使用していますが、グラフを表示(プロット)します。しかし、私は、周波数成分を変数に格納したいだけですが、私はどのようにしてか分かりません。 コードに該当しない場合は誰でも私にMatlabやJavaで動作するコードを教えてもらえますか?MATLABまたはJavaのFFT

注:私は信号処理やMATLABの専門家ではありません。あなたの質問でのMATLABコードで


%% Basic Fourier Analysis 
    % This example uses the Fourier transform to identify component 
    % frequencies in a simple signal. 

    %% 
    % Create a time vector |t| and a sinusoidal signal |x| that is a  function of |t|. 
    t = 0:1/50:10-1/50;      
    x = sin(2*pi*15*t) + sin(2*pi*20*t); 

    %% 
    % Plot the signal as a function of time. 
    plot(t,x) 

    %% 
    % Compute the Fourier transform of the signal, and then compute the magnitude 
    % |m| and phase |p| of the signal. 
    y = fft(x);   
    m = abs(y);        
    p = angle(y);      

    %% 
    % Compute the frequency vector associated with the signal |y|, which is 
    % sampled in frequency space. 
    f = (0:length(y)-1)*50/length(y); 



    %% 
    % Plot the magnitude and phase of the signal as a function of frequency. 
    % The spikes in magnitude correspond to the signal's frequency 
    % components. 
    subplot(2,1,1) 
    plot(f,m) 
    title('Magnitude') 

    subplot(2,1,2) 
    plot(f,rad2deg(p)) 
    title('Phase') 

    %% 
    % Compute and plot the inverse transform of $y$, which reproduces the 
    % original data in $x$ up to round-off error. 
    figure 
    x2 = ifft(y); 
    plot(t,x2) 
+1

試してみてください。私はこのコードがあなたによって書かれていないことを理解しています。 – Roxanne

+0

はい私はmatlabのサイトでそれを見つけました –

+0

私はこれをh = fft(t、x2)のように保存しようとし、次にx_h = h.x y_h = h.y –

答えて

2

ベクトルm大きさ、各FFT出力ビンのが含まれています。各ビンは周波数に対応しているため、このビンは各ビン周波数で大きさを示します。スペクトルの最大ピークの周波数を探している場合は、最大値をmで見つけ、このピーク値のビン指数を周波数に変換します。ビンインデックスと周波数との関係は次式で与えられる。

関心のあるビンのインデックスで iFsは、サンプルレートで
f = i * Fs/N 

NはFFTサイズであり、そしてfは、対応するビンの中心周波数です。詳細については、this questionを参照してください。