필터 지우기
필터 지우기

Extract Corresponding Frequency value from the peak amplitude

조회 수: 3 (최근 30일)
Rajesh Kanesan
Rajesh Kanesan 2022년 9월 25일
댓글: Rajesh Kanesan 2022년 9월 26일
I have started this code to decode and detect the DTMF character from the wavfile. I am very new to MATLAB and need a urgent help to extract the corresponding frequencies (x-axis) from the peak value (locs) so that i can complete my assignment.
close all;
clear all;
clc;
% Load file, obtain information and play sound
Dialtone = 'DTMFDigit1.wav'; % Input Tone
audioread(Dialtone); %To read the wave file
info = audioinfo(Dialtone);
display(info); % Verify the sudio information
[Dialtone, fs] = audioread(Dialtone); % To obtain the sample rate
sound(Dialtone, fs) % Play Sound
% Plot of the DTMF tone in time domain
N = length(Dialtone); % Obtain total number of samples
idx = 0:N-1;
t = idx*(1/fs);
figure(1);
plot(t, Dialtone) % Plot the signal in time domain
title('Dial Tone Time Waveform'); % plot title3
xlabel('Time'), ylabel('Amplitude'); % plot axis labels
% Plot of the DTMF tone in Frequency domain
n = 2^nextpow2(N); % identify an input length that is the next power of 2
Y = fft(Dialtone,n);
P2 = abs(Y/n);
P1 = P2(1:n/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = fs*(0:(n/2))/n;
figure(2);
plot(f,P1)
title("Single-Sided Amplitude Spectrum of Dialtone")
title("Single-Sided Amplitude Spectrum of Dialtone")
xlabel("frequency (Hz)")
ylabel("|P1(f)|")
[pks,locs] = findpeaks(abs(P1),'SortStr','descend','NPeaks',2);

답변 (1개)

KSSV
KSSV 2022년 9월 26일
  댓글 수: 1
Rajesh Kanesan
Rajesh Kanesan 2022년 9월 26일
Thanks for your response , I have started this code to decode and detect the DTMF character from the wavfile using the FFT approach. I am very new to MATLAB and need a urgent help to extract the corresponding frequencies (x-axis) from the peak value (locs) so that i can complete this assignment.I wish to get the result in the order of X-axis , frequency rather than the sorted Y-axis peak amplitude value. Could you please help as my assignement due in 24hours?

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by