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');