% generating signal x1 Fs = 100; % sampling frequency t = [0 : 1/Fs : 10]; x1 = 4 * cos(2 * pi * 3.5 * t - ((30*pi)/180)); % 1000 and 4000 point fft of signal x1 X1000 = fft(x1, 1000); X1000_mag = abs(X1000); % magnitude spectrum X1000_mag = fftshift(X1000_mag); X1000_phase = angle(X1000); % phase spectrum X1000_phase = fftshift(X1000_phase); X4000 = fft(x1, 4000); X4000_mag = abs(X4000); % magnitude spectrum X4000_mag = fftshift(X4000_mag); X4000_phase = angle(X4000); % phase spectrum X4000_phase = fftshift(X4000_phase); % plots the 1000 and 4000 point magnitude and phase spectrums N1000 = length(X1000); N4000 = length(X4000); F1000 = Fs * [-N1000/2: N1000/2 - 1]/N1000; F4000 = Fs * [-N4000/2: N4000/2 - 1]/N4000; figure; hold on; plot(F1000, X1000_mag); plot(F4000, X4000_mag); xlabel('Frequency (Hz)'); ylabel('Magnitude (A.U.)'); title('Magnitude Spectrum of Signal x1'); figure; hold on; plot(F1000, X1000_phase); plot(F4000, X4000_phase); xlabel('Frequency (Hz)'); ylabel('Phase (rads)'); title('Phase Spectrum of Signal x1'); % generating signal x2 and x_tot x2 = 3 * cos(2 * pi * 3.62 * t); x_tot = x1 + x2; % 1000 and 4000 point fft of signal x_tot X1000_tot = fft(x_tot, 1000); X1000_tot_mag = abs(X1000_tot); % magnitude spectrum X1000_tot_mag = fftshift(X1000_tot_mag); X1000_tot_phase = angle(X1000_tot); % phase spectrum X1000_tot_phase = fftshift(X1000_tot_phase); X4000_tot = fft(x_tot, 4000); X4000_tot_mag = abs(X4000_tot); % magnitude spectrum X4000_tot_mag = fftshift(X4000_tot_mag); X4000_tot_phase = angle(X4000_tot); % phase spectrum X4000_tot_phase = fftshift(X4000_tot_phase); % plots the 1000 and 4000 point magnitude and phase spectrums figure; hold on; plot(F1000, X1000_tot_mag); plot(F4000, X4000_tot_mag); xlabel('Frequency (Hz)'); ylabel('Magnitude (A.U.)'); title('Magnitude Spectrum of Signal xtot'); figure; hold on; plot(F1000, X1000_tot_phase); plot(F4000, X4000_tot_phase); xlabel('Frequency (Hz)'); ylabel('Phase (rads)'); title('Phase Spectrum of Signal xtot');