Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fs = 1000; T = 1/Fs; 2000; % sampling frequency % sampling period % Length of si

ID: 2267554 • Letter: F

Question

Fs = 1000; T = 1/Fs; 2000; % sampling frequency % sampling period % Length of signal % Time vector S % use for loop to generate sguare waveform with 1000 sin wave components % Plot in time domain plot (1000*t, S) title('Signal') xlabel ('t (milliseconds) ') ylabel('X (t) % Fourier transform Y-fft (S) F Es(0 (L/2))/L; P2 abs (Y/L) P1P2 (1:L/2+1) PI (2 : end-1) -2*PI (2 : end-1) ; % Plot in frequency domain plot (F, P1) title('Single-Sided Amplitude Spectrum of S(t)) xlabel (' (Hz)) ylabel ('P1(E)I 1. Now add more frequency components together. Use 1000 frequency components, each component 2. 3. has an odd increase of frequency and odd decrease of amplitude. Use for loop to achieve it Add all the components together. Scale it with the factor 4/t. Transform it into frequency domain.

Explanation / Answer

% FOLLOWING PROGRAM WILL HELP YOU TO DRAW A SQUARE WAVEFORM BY USING 1000 SIN TERMS AND TO PLOT FREQUENCY SPECTRUM

% 1000 wave forms and frequency spectrum
clc;
clear all;
Fs = 1000;
T = 1/Fs;
L = 2000; % L = 2000
t = 0:2:1000;
S = 0;
for k = 1 : 2 : 1000; % t = (0 : L-1)*L;
S = S + sin(k*t)/k;
end
plot (t,S)
% plot
plot (1000*t, S);
title ('signal');
xlabel(' t (milli seconds)');
ylabel ('X(t)');

% Fourier transform
Y = fft(S);
F = Fs * ((0:L/4))/L; % F and P1 vector dimensions must match
P2 = abs(Y/L);
P1 = P2(1:(L/4)+1);
P1(2:end-1) = 2* P1(2:end-1);
figure
% plot in frequency domain
plot(F,P1);
title ('Single sided Amplitude spectrum of S(t)');
xlabel ('f (Hz)');
ylabel ('|P1(F)|');