Reproduce Figures 9.2b and 9.2c on MATLAB, assuming that the
square wave (Figure 9.2b) is a periodic symmetric square wave of
normalized amplitude (A=1). Each student group should
decide the power spectral density level of the channel noise.
Compute the Fourier transform of the periodic square wave.

clear all
close all
%%%%
T=12*pi; %number of period
x=linspace(0,T);
t=x/pi
y0=square(x); %square wave signal
y0ft=fft(y0); %calculating Fourier Transformof signal
y0fts=fftshift(y0ft);
y0ftFinal=abs(y0ft);
AWGN= rand(size(x)); %Calculating whit noise
Att=(1/3);
nSig= Att*AWGN;
y=y0+nSig; %Square wave signal with Gaussian noise
yft=fft(y); %Calculating Fourier Transform of new signal
yfts=fftshift(yft);
yftFinal=abs(yfts);
%%%%
subplot(2,1,1);
plot(t,y0)
title("Originalsignal without noise")
xlabel("period")
ylabel("Magnitude")
grid on
%%%
figure
subplot(2,1,1);
plot(t,y0ftFinal)
title("Fourier Transform of original signal")
xlabel("Period")
ylabel("Magnitude")
grid on
subplot(2,1,1);
plot(t,yftFinal)
xlabel("Period")
ylabel("Magnitude")
title("Fourier transform of original signal with noise")
grid on
.
MATLAB code with comments for explanation is given below in bold letters, followed by the results.
clc;
close all;
clear all;
% define time T
T = 12*pi;
% frequency of square wave
f = 1/(4*T);
% define the sampling time
fs = 1;
% define time t
t = 0:1/fs:10*T;
% percentage Duty cycle
D =25;
% define the signal s(t)
s = square(2*pi*f*t,D);
% plot the signal
figure;
plot(t,s);grid on;ylim([-5 5]);xlim([0 6*T]);
title('original signal s(t)');
% now define the noise
AWGN= rand(size(s));
Att=(1);
nSig= Att*AWGN;
% add the noise to signal
y=s+nSig; %Square wave signal with Gaussian noise
% plot the noise contaminated signal
figure;
plot(t,y);grid on;ylim([-5 5]);xlim([0 6*T]);
title('noisy signal y(t)');
% take the fft of the original signal
% Finding FFT of s(t)
N = nextpow2(length(s));
S = fftshift(fft(s,2^N));
S = 2*S/length(s);
k = -(length(S)-1)/2:1:length(S)/2;
f = k/length(S) * fs;
figure;plot(f,abs(S));grid;
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Double sided Magnitude spectrum of original signal
s(t)');
xlim([-1 1]);
% take the fft of the noise contaminated signal
% Finding FFT of y(t)
N = nextpow2(length(y));
Y = fftshift(fft(y,2^N));
Y = 2*Y/ length(y);
k = -(length(Y)-1)/2:1:length(Y)/2;
f = k/length(Y) * fs;
figure;plot(f,abs(Y));grid;
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Double sided Magnitude spectrum of noisy signal
y(t)');
xlim([-1 1]);





Reproduce Figures 9.2b and 9.2c on MATLAB, assuming that the square wave (Figure 9.2b) is a...
Exercise 4. Computing and displaying the Fourier Transform of a signal Later in the semester it will become useful to determine the frequency response of a signal or system by taking the Fourier Transform empirically (rather than computing it analytically). To do so we make use of the fft and fftshift commands. The fft command is an efficient implementation of the Discrete Fourier Transform (DFT) known as the Fast Fourier Transform (FFT). When the FFT is computed the samples are...
Execute the function, using 11 as Non, and 8 as Noff. function fourier_example(Non,Noff) %this function demonstrates fourier analysis and synthesis for a simple %periodic rectangular wave of varying duty cycle. %Inputs: Non= integer number of seconds per period that the signal is on % Noff = integer number of seconds per period the signal is off t=-30:.001:30; %time scale Nharm = 20; %number of harmonics to calculate %construct a periodic square-wave with desired duty cycle x=zeros(size(t)); for k1=-Nharm:Nharm x =...
Need help converting the following code from Matlab into Python: N=2048; fs=4.9; t=0:1/fs:(N-1)/fs; fs1=200; t1=0:1/fs1:(N-1)/fs1; x2=0.5+0.6366.*cos(2.*pi.*t1)+0.1273.*cos(10.*pi.*t1)-0.0909.*cos(14.*pi.*t1); x=0.5+0.6366.*cos(2.*pi.*t)+0.1273.*cos(10.*pi.*t)-0.0909.*cos(14.*pi.*t); X=fftshift(fft(x)); f=linspace(-fs/2,fs/2,N); plot(f,abs(X)./N); xlabel('f'); ylabel('|F(f)|'); title('magnitude spectrum of sampled signal'); x1=ifft(fftshift(X)); figure plot(t(1:100),x1(1:100)); xlabel('t'); ylabel('f(t)'); title('f(t) obtained by inverse transform'); figure plot(t1(1:1000),x2(1:1000)); xlabel('t'); ylabel('f(t)'); title('original f(t)');
Program from problem 1: (Using MATLAB)
% Sampling frequency and sampling period
fs = 10000;
ts = 1/fs;
% Number of samples, assume 1000 samples
l = 1000;
t = 0:1:l-1;
t = t.*ts; % Convert the sample index into time for generation and
plotting of signal
% Frequency and amplitude of the sensor
f1 = 110;
a1 = 1.0;
% Frequency and amplitude of the power grid noise
f2 = 60;
a2 = 0.7;
% Generating the sinusoidal waves...
I need help in MATLAB. I'm working on a circuits lab report and I want to plot the derivative of an input signal. The circuit is a differentiator OpAmp. It is receiving a triangle wave as an input and should output a square wave. (I've included my existing code.) The output formula is: Vout = -(Rf)*C*(dVin/dt) Where Rf is feedback resistance: Rf = 1*10^6; and C = 1*10^-6. EXISTING CODE: %% This section is copied, and then modified from another...
I wrote a Matlab program for the figure below. When I plot the waves, they look the same. Why do the two waves frequencies look same and How do I avoid it? (I really do need this part of the question answered.) N = 200; % Total number of time domain samples in simulation. Fs = 100 ;% sampling frequency. F1 = 10; % frequency of wave - 1. F2 = 90; % frequency of wave - 2. phi =...
Exercises: u used to the instructor b the end of next lab. 20 102 Plot the f(t)-sinc(20r) cos(300t)sinc (10t) cos(100t) Use the fast Fourier transform to find the magnitude and phase spectrum of the signal and plot over an appropriate range. Use appropriate values for the time interval and the sampling interval. Note that in Matlab sinc(x)-, so we need to divide the argument by n to make it match the given function. Le, sinc(20t/pi) Hint: Use the parameters from...
how to do laplace transform on a signal that is in frequency domain. I have a signal that is in time domain and i used fft to plot it in the frequency domain, is there a way i could plot it in s domain. I know that i could do laplace transform directly from time domain to s domain, but I need to find out are these two results match each other. Fs = 4; % samples per second dt...
Part 1: Exponential Fourier series The following MATLAB code calculates the exponential Fourier series coefficient for the signal x(t) shown in the figure below, plots it's double sided amplitude spectrum IDn l, double sided phase spectrem LDn, and the resulting signal xn(t). 4r 4a Periodic signal x(t) 1.1 Show that the complex Fourier Series Coefficients written as: D 1.2 Use the following Matlab to general the two sided spectral line. 1.3 Execute the Matlab code with To = 2π and...
Amplitude=3; fs=8000; n=0:399; t=0:1/fs: n*1/fs-1/fs; signal=3+3*cos(2*pi*1100*t)+3*cos(2*pi*2200*t)+3*cos(2*pi*3300*t); fftSignal= fft(signal); fftSignal=f ftshift (fftSignal); f=fs/2*linspace(-1,1,fs); plot(f,abs(fftsignal); xlabel('Frequency(Hz)’) ylabel('amplitude(v)') title('Spectral domain') plz code above using For ..End loop to archive the same results.