1
$\begingroup$

I am looking clarification that I have the appropriate solution to this question, thoughts and tips to improve my understanding are also welcome!

f(n) is a discrete sample of the following signal. The sample rate is $4$ Hz and the time period is from $0 - \frac{3}{4}$

$$ f(t) = 5+2\cos(2\pi t - \pi/2)+ 3\cos(4\pi t)$$

Define the number of samples

I am unsure if there are $3$ samples as $4 \cdot \frac{3}{4}$ or there are $12$ samples as per the vector in the code? $\frac{3}{4}$ divided by the sampling rate..

Plot the amplitude and angle spectra.

fs = 4;
t = (0:(0.75/(fs*3-1)):0.75); % time vector of 0-0.75 split into 12 samples
x = 5+2*cos(2*pi*t-pi/2)+3*cos(4*pi*t); % signal

% calculate the DFT of the signal
Xk = fft(x);
amp = abs(Xk);
phase = angle(Xk);

subplot(2,1,1)
stem(amp)
title('Amplitude spectrum');
xlabel('Frequency (Hz)');
ylabel('Amplitude');

subplot(2,1,2)
stem(phase)
title('Angle spectrum');
xlabel('Frequency (Hz)');
ylabel('Phase');
$\endgroup$

1 Answer 1

2
$\begingroup$

If the sampling rate is $4 ~ Hz$ then in a time period of $1 ~ s$ you are to acquire $4$ samples. Thus, for a time period of $\frac{3}{4} ~ s$ you would get $\lfloor\frac{3}{4} \cdot 4 \rfloor$ samples where the $\lfloor \cdot \rfloor$ denotes the "floor" function which gives you the integral part of a decimal number.

Thus, for your problem at hand you would end up with $3$ samples, no matter what the analogue signal to be discretised is.

One more thing to note is that in order to calculate the time values for which an (ideal) sampler would get samples from an analogue signal all you have to do is (in MATLAB/Octave code)

fs = 4; % Sampling rate (in Hz)
dt = 1/fs; % Sampling interval/period (in reciprocal frequency dimension - here seconds)
dur = 1; % Duration of sampling (same dimension as dt)
t = 0:dt:(dur * fs) - dt; % Time vector

So I think that your version is not correct (I might be missing something though).

$\endgroup$
1
  • 1
    $\begingroup$ hello my friend, yes you are correct I confirmed with my lecturer. that is a good tip for calculating time values. thanks. $\endgroup$
    – Tam
    Commented Feb 24, 2023 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.