0% found this document useful (0 votes)
4 views6 pages

CS Assignment 1

The document outlines an assignment for a Circuit Simulation Laboratory, requiring the generation of various periodic and aperiodic signals using MATLAB, including square, exponential, ramp, and sinusoidal waveforms. It details the implementation of these signals in MATLAB, including plotting and Fourier analysis of a composite signal made from 50 Hz and 120 Hz sinusoids. The conclusion emphasizes the successful generation and analysis of these signals using MATLAB functions.

Uploaded by

amrutamhetre9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

CS Assignment 1

The document outlines an assignment for a Circuit Simulation Laboratory, requiring the generation of various periodic and aperiodic signals using MATLAB, including square, exponential, ramp, and sinusoidal waveforms. It details the implementation of these signals in MATLAB, including plotting and Fourier analysis of a composite signal made from 50 Hz and 120 Hz sinusoids. The conclusion emphasizes the successful generation and analysis of these signals using MATLAB functions.

Uploaded by

amrutamhetre9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Circuit Simulation Laboratory

Assignment 1
Write a MATLAB program for generations of following periodic/ aperiodic signals ,

a) Square, exponential (decay and rising), Ramp.


b) Generate a sinusoidal waveforms x1(n) and x2(n) of 50 Hz and 120Hz respectively.
Generate a composite signal which is addition of these two sinusoids. Find the spectrum
of signal using Fourier analysis.

Plot the same using MATLAB subplot function, label the axis and title each subplot.

Part a)
%Write a MATLAB program for generations of following periodic/ aperiodic
signals :
% Square, exponential(decay and rising), Ramp.
x=0:0.01:20;
y1=sin(x);
y2=cos(x);
y3=square(x,50);
y5=exp(x);
y6=exp(x).^-1;

subplot(3,2,1);
plot(x,y1);
xlabel('X-axis');
ylabel('Sin(x)');
title('Subplot 1: sin(x)');

subplot(3,2,2);
plot(x,y2);
xlabel('X-axis');
ylabel('cos(x)');
title('Subplot 2: cos(x)');

subplot(3,2,3);
plot(x,y3);
xlabel('X-axis');
ylabel('square(x)');
title('Subplot 3: square(x)');

subplot(3,2,4);
plot(x,x);
xlabel('X-axis');
ylabel('ramp(x)');
title('Subplot 3: ramp(x)');

1
Circuit Simulation Laboratory

subplot(3,2,5);
plot(x,y5);
xlabel('X-axis');
ylabel('exp(x)');
title('Subplot 3: exponential rising');

subplot(3,2,6);
plot(x,y6);
xlabel('X-axis');
ylabel('exp(-x)');
title('Subplot 3: exponential decay');

Fig 1.1 Sine, Cosine, Ramp, Exponential rising and decaying signals

2
Circuit Simulation Laboratory

Part b)
%Generate a sinusoidal waveforms x1(n) and x2(n) of 50 Hz and 120Hz
respectively.
%Generate a composite signal which is addition of these two sinusoids.
%Find the spectrum of signal using Fourier analysis.

Fs = 1000; % Sampling frequency


T = 1/Fs; % Sample time
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector

% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid


subplot(2,1,1);
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
plot(Fs*t(1:50),x(1:50));
title('Composite signal(addition of 50hz and 120hz sinusoidal waveforms)');
xlabel('time (milliseconds)')
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(x,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);

% Plot single-sided amplitude spectrum.


subplot(2,1,2);
plot(f,2*abs(Y(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

3
Circuit Simulation Laboratory

Fig 1.2 Composite signal, Single sided Amplitude spectrum

INFORMATION:-

FFT:

4
Circuit Simulation Laboratory

PLOT:

SUBPLOT:

5
Circuit Simulation Laboratory

Conclusion:-
Thus, we have generated different signals such as ramp, square, exponential, sine using the basic
functions in the MATLAB. Also we have generated a composite signal which is addition of two
sinusoids .Taking fast Fourier transform of the mixed sum of two sinusoidal signals we plot its
amplitude spectra taking absolute value using abs( ) function in the MATLAB.

You might also like