필터 지우기
필터 지우기

Frequency doesn't sound right

조회 수: 2 (최근 30일)
Tom
Tom 2012년 2월 5일
Hey, I'm just doing a tutorial for a course I'm doing and one question asks us to recover 'signal 2', where we're given signal 1 (x), and the combination of signal 1 & 2 (z).
Whether or not my process is right or not, there's something I'd like to ask. I thought I'd listen back to signal 2 (y(t) in this case). When looking at the graph of y(t), it's clear that the period T is 0.0025 sec. The inverse of this gives the frequency of the sound - 400 Hz. When I listen to this however, it sounds significantly lower than a tone at 400 Hz.
Is it something to do with my sampling frequency, or my number of points?
And here's my code: -
close all; clear all;
[x,fs] = wavread('signal_1');
x = transpose(x);
[z,fs] = wavread('signal1and2');
z = transpose(z);
N = length(x); %Number of points
i_nyquist = N/2+1; %index of nyquist frequency
dt = 1/fs; %sampling interval or sampling period
t = (([1:N]-1)/fs); %Time axis
posfreq = fs*([1:i_nyquist]-1)/N; %positive frequency axis
negfreq = fs*([i_nyquist:(N-1)]-N)/N;%negative frequency axis
X = (fft(x,N)); %Transform into frequency domain using FFT
Z = (fft(z,N)); %Transform into frequency domain using FFT
Y = (Z./X); %Y in the frequency domain
y = ifft(Y); %Transform into time domain using inverse FFT
sound(y)

채택된 답변

Daniel Shub
Daniel Shub 2012년 2월 6일
The function sound uses a sample rate of 8192 unless you give it something else. My guess is you want
sound(y, fs);
You code also assumes that x and z have the same lengths and sample rates.
  댓글 수: 1
Tom
Tom 2012년 2월 7일
Thanks Daniel, that sorted it. They did have the same length and sample rates, but yeah I needed to add the 'fs' into the sound command to get it sounding at the correct pitch.
Many thanks.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Measurements and Spatial Audio에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by