필터 지우기
필터 지우기

Something is wrong with my FFT results

조회 수: 10 (최근 30일)
Nathan Lively
Nathan Lively 2022년 3월 9일
답변: Nathan Lively 2022년 3월 10일
I've been over this for a couple of hours and I can't find where the error is. I just want to confirm that at each step of the process that I'm doing it correctly so all of the outputs should match.
  1. Import loudspeaker response data in magnitude and phase.
  2. Convert to complex number.
  3. Interpolate.
  4. IFFT
The first three steps return matching plots, but the plot of the fourth step has something wrong with it. What am I doing wrong??
And here's the magPhase2complex function I made:
function Z = magPhase2complex(mag_dB,phase_deg)
Z = [db2mag(mag_dB) .* exp(1j*(deg2rad(phase_deg)))];
end
some n
% Get some Data
CSVmainFile = '/Users/nathanlively/Downloads/PRX615M_Main.csv';
M_TF = readtable(CSVmainFile,'ReadVariableNames',false);
M_TF.Properties.VariableNames = {'frequency','magnitude','phase','coherence'};
% Convert to complex
M_TF.Z = magPhase2complex(M_TF.magnitude,M_TF.phase);
% Interpolate and fill missing
newFs = 192000;
main = timetable('SampleRate',newFs);
main.Hz = linspace(0,newFs,newFs)';
main.Z = interp1(M_TF.frequency,M_TF.Z,main.Hz,'pchip',NaN);
main.Z = fillmissing(main.Z,'nearest','EndValues','extrap');
main.magnitude = mag2db(abs(main.Z));
% IFFT
main.IR = real(ifft(main.Z)) * height(main);
main.Zrecon = fft(main.IR) / height(main);
main.magnitudeRecon = mag2db(2*abs(main.Zrecon));
semilogx(M_TF.frequency,M_TF.magnitude, main.Hz,main.magnitude, main.Hz,main.magnitudeRecon)
xlim([20 20000]);ylim([max(M_TF.magnitude)-10 max(M_TF.magnitude)]);
legend('original','interp1','reconstructed magnitude','FontSize',22)
  댓글 수: 16
Bjorn Gustavsson
Bjorn Gustavsson 2022년 3월 10일
@Chris Turnes - fair points, the question just struck me as I read your description, and thought that "the optimal procedure surely ought to be the averages of the real and the conjugated complex parts". But I see the use-case and that my flicker of an idea doesn't really apply...
Nathan Lively
Nathan Lively 2022년 3월 10일
@Paul Generate a new spectrum, that starts at f =,0, is equally spaced at 1 Hz, and finishes at Fs/2 = 192000/2?
Exactly!
If so what is the use of that end product?
One of the problems I was running into is that I want to window the IFFT data at a specific lenght in milliseconds. With the "dirty" data I am not able to calculate the time vector to go along with the IFFT.

댓글을 달려면 로그인하십시오.

채택된 답변

Nathan Lively
Nathan Lively 2022년 3월 10일
Although I'm not 100% this is correct, so far the answer I mentioned in this comment seems to be working. I just needed to replace the beginning and end values with zeros.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by