# Homework Help: Problems regarding signal sampling

1. Mar 23, 2016

### haha1234

1. The problem statement, all variables and given/known data
I have created four signals in Matlab and we need to play the sound of these signals.
The four signals I've created are:

n=[0:8191];
w0=2*pi*2000;
T=1/8192;
t=[0,1];
t=n*T;
x=sin(w0*t);
sound(x,1/T);
-----------------

n=[0:8192];
w0=2*pi*2000;
T=1/8192;
t=[0,1];
t=n*T;
x=sin(w0*t);
[X,f]=ctfs(x,T);
sound(X,1/T);
-------------------------
n=[0:8191];
w0=2*pi*3000;
T=1/8192;
t=[0,1];
t=n*T;
x=sin(w0*t);
sound(x,1/T);
--------------------
n=[0:8192];
w0=2*pi*3000;
T=1/8192;
t=[0,1];
t=n*T;
x=sin(w0*t);
stem(x(1:50));
---------------------
The function ctfs is defined as:

function [X,f] = ctfts(x,T)
% CTFTS calculates the continuous
-
time Fourier transform (CTFT) of a
% periodic signal x(t) which is reconstructed from the samples in the
% vector x using ideal band
limited interpolation. The vector x
% contains samples of x(t) over an integer number of periods, and T
% contains the sampling period.
%
% The vector X contains the area of the impulses at the frequency
% values stored in the vector f.
%
% This function m
akes use of the relationship between the CTFT
% of x(t) and the DTFT of its samples x[n], as well as the
% relationship between the DTFT of the samples x[n] and the DTFS of x[n].
N = length(x);
X = fftshift(fft(x,N))*(2*pi/N);
f = linspace(-1,1-2/N,N)/(2*T);

The w0 of the first two signals is 2*pi*2000 and the w0 of the last two signals is 2*pi*2000.
Why the pitch of the signals increase as the w0 increase when we do not apply the ctfs function, while the pitches are the same when we apply the function?
2. Relevant equations
3. The attempt at a solution

I tried to find out the reason why by deriving the Fourier series of the sampled signals.
And the results are shown below:

For w0=2*π*2000:
The Fourier series is:
x[n]=sin(2π*2000*n/8192)
=sin(125πn/256)
=1/2ej125πn/256-1/2e-j125πn/256

For w0=2*π*3000:
The Fourier series is:
x[n]=sin(2π*3000*n/8192)
=sin(375πn/512)
=1/2ej375πn/512-1/2e-j375πn/512

From these results, I found the magnitude spectra and I discovered that the distance between each magnitude components(?) getting longer as the w0 increase. Therefore, I think the pitch should be decrease with the increase of w0.

On the other hand, I have no idea why the pitch does not change when we add the function ctfs?

Thanks!

2. Mar 23, 2016

### .Scott

You meant 2*pi*3000 for the last two.
Also:
* your function name is ctfts, but you call it ctfs
* sound requires a real array, you are providing a complex array - use abs().
* The code you provided for creating the 3000 Fourier sound doesn't do that.
Any variation of the Fourier Transform should put you in the frequency domain. I haven't looked at your ctfs function in detail, but I accept that it qualifies as a "variation of the Fourier Transform".
When taking the FT of a signal, a change in frequency (from 2000 to 3000) should result in a shift in the FT. So, for example, in the 2*pi*2000 case, you would get a peak at 2000 and perhaps some harmonics. And with 2*pi*3000, you would get a peak at 3000 and some harmonics. If those harmonics were strong, you might notice a pitch change, but with sine waves, they are probably inaudible. So would you should get is a click - the same click in both cases, just slightly more delayed for the 3000Hz case.

3. Mar 23, 2016

### .Scott

So with 2*pi*2000, you get clicks at 4096 +/- 2000. With 2*pi*3000, you get clicks at 4096 +/- 3000.
In both cases you get 2 clicks, but the clicks are spaced further apart with 3000.