필터 지우기
필터 지우기

rotated plot gone wrong

조회 수: 3 (최근 30일)
Sonia
Sonia 2022년 12월 21일
댓글: William Rose 2022년 12월 21일
I have the following code in matlab and the image "Figure 2" is plot 3 of the code but it should not come out like this. Please help me correct the code and make the image look like the image "Figure_1YES". This is te audio
fc1=0.125;
fc2=0.25;
f=[fc1,fc2];
h=fir1(64,f,'bandpass');
[data]=audioread("Domini_Fil.wav");
figure();
plot(data)
filteredData=filtfilt(h,1,data);
figure();
plot(filteredData);
[w,rh]=freqz(h,1,64);
w_pi=(w/pi)*6;
figure();
plot(abs(w_pi),abs(rh));
figure();
fft_input=fft(data);
plot(abs(fft_input));
figure();
fft_output=fft(filteredData);
plot(abs(fft_output));
%sound(data);
sound(filteredData);
pause(d+1);

답변 (2개)

Voss
Voss 2022년 12월 21일
You've got the outputs from freqz reversed:
[w,rh]=freqz(h,1,64);
The frequency response is first, and the angular frequencies are second:
[rh,w]=freqz(h,1,64);
Try it like that.

William Rose
William Rose 2022년 12월 21일
Change
[w,rh]=freqz(h,1,64);
to
[rh,w]=freqz(h,1,64);
Good luck.
  댓글 수: 1
William Rose
William Rose 2022년 12월 21일
The attached code is your code, but now the horizontal axis scale is time in seconds (instead of sample number) or frequency in Hertz (instead of frequency sample number). Using actual physical units such as secodns and Hertz helps the viewer understand the data better, in most cases. You can determine the frequencies in Hertz by getting the sampling rate in Hz, fs, from audioread().
I combined plots 1 and 2 into a single figure to make it easier to compare the signal before and after filtering. I did the same thing with plots 4 and 5. I also changed the frequency axis scale to show only the frequencies of the FFT up to the Nyquist frequency. The FFT amplitude above the Nyquist frequency is the mirror image of the FFT amplitude below the Nyquist frequency, so the data above conveys no additional information. That is why I choose not to include it in the plot.
Good luck with your work.

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

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by