0% found this document useful (0 votes)
44 views13 pages

MATLAB For Basic Electrical Engineering

The MATLAB program generates various common signals and sequences, including unit impulse, unit step, unit ramp, sinusoidal, square, sawtooth, triangular, and sinc signals. It uses plotting and stem functions to display the continuous and discrete versions of each signal type in the time domain.

Uploaded by

Nandan N
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)
44 views13 pages

MATLAB For Basic Electrical Engineering

The MATLAB program generates various common signals and sequences, including unit impulse, unit step, unit ramp, sinusoidal, square, sawtooth, triangular, and sinc signals. It uses plotting and stem functions to display the continuous and discrete versions of each signal type in the time domain.

Uploaded by

Nandan N
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/ 13

GENERATION OF VARIOUS SIGNALS&SEQUENCES

AIM:- To write a “MATLAB” Program to generate various signals and sequences,such as

unit impulse, unit step, unit ramp, sinusoidal,square,saw tooth,triangular,sinc signals.

SOFTWARE REQURIED:-

1.MATLAB R2010a.

2.Windows XP SP2.

THEORY:-

One of the more useful functions in the study of linear systems is the "unit impulse function."

An ideal impulse function is a function that is zero everywhere but at the origin, where it is

infinitely high. However, the area of the impulse is finite. This is, at first hard to visualize but

we can do so by using the graphs shown below.


Key Concept: Sifting Property of the Impulse
If b>a, then
Example: Another integral problem
Assume a<b, and evaluate the integral
Solution:
Solution:
We now that the impulse is zero except at t=0 so
And
Unit Step Function

The unit step function and the impulse function are considered to be fundamental functions in

engineering, and it is strongly recommended that the reader becomes very familiar with both of

these functions.

The unit step function, also known as the Heaviside function, is defined as such:

Sometimes, u(0) is given other values, usually either 0 or 1. For many applications, it is
irrelevant what the value at zero is. u(0) is generally written as undefined.
Derivative
The unit step function is level in all places except for a discontinuity at t = 0. For this reason, the
derivative of the unit step function is 0 at all points t, except where t = 0. Where t = 0, the
derivative of the unit step function is infinite.
The derivative of a unit step function is called an impulse function. The impulse function will
be described in more detail next.
Integral
The integral of a unit step function is computed as such:

Sinc Function
There is a particular form that appears so frequently in communications engineering, that we
give it its own name. This function is called the "Sinc fu
The Sinc function is defined in the following manner:

And
Sinc(0)=1
The value of sinc(x) is defined as 1 at x = 0, since

This fact can be proven by noting that for x near 0,

Then, since

Then, since cos(0) = 1, we can apply the approaches one as x goes to zero. Thus, defining s

continuous.

Also, the Sinc function approaches zero as x goes towards infinity, with the envelope of sinc(x)
tapering off as 1/x.
Rect Function

The Rect Function is a function which produces a rectangular

centered at t = 0. The Rect function pulse also has a height of 1. The Sinc function and the

rectangular function form a Fourier transform pair.

A Rect function can be written in the form:

where the pulse is centered at X and has width Y. We can define the impulse function above in
terms of the rectangle function by centering the pulse at zero (X = 0), setting it's height to 1/A
and setting the pulse width to A, which approaches zero:

We can also construct a Rect function out of a pair of unit step functions

Here, both unit step functions are set a distance of Y/2 away from the center point of (t - X).

SAW TOOTH:-

The sawtooth wave (or saw wave) is a kind of non-sinusoidal waveform. It is

named a sawtooth based on its resemblance to the teeth on the blade of a saw. The

convention is that a sawtooth wave ramps upward and then sharply drops. However, there

are also sawtooth waves in which the wave ramps downward and then sharply rises. The

latter type of sawtooth wave is called a 'reverse sawtooth wave' or 'inverse sawtooth

wave'. As audio signals, the two orientations of sawtooth wave sound identical. The

piecewise linear function based on the floor function of time t, is an example of a

sawtooth wave with period 1.


Triangle wave

A triangle wave is a non-sinusoidal waveform named for its triangular shape.A

bandlimited triangle wave pictured in the time domain (top) and frequency domain

(bottom). The fundamental is at 220 Hz (A2).Like a square wave, the triangle wave

contains only odd harmonics. However, the higher harmonics roll off much faster than in

a square wave (proportional to the inverse square of the harmonic number as opposed to
just the inverse).It is possible to approximate a triangle wave with additive synthesis by
adding odd harmonics of the fundamental, multiplying every (4n􀀀1)th harmonic by 􀀀1
(or changing its phase by 􀀀), and rolling off the harmonics by the inverse square of their
relative frequency to the fundamental.This infinite Fourier series converges to the triangle
wave:

Sinusoidal Signal Generation


The sine wave or sinusoid is a mathematical function that describes a smooth repetitive
oscillation. It occurs often in pure mathematics, as well as physics, signal processing,
electrical engineering and many other fields. Its most basic form as a function of time (t)
is:
where:
• A, the amplitude, is the peak deviation of the function from its center position.
• 􀀀, the angular frequency, specifies how many oscillations occur in a unit time
interval, in radians per second
• 􀀀, the phase, specifies where in its cycle the oscillation begins at t = 0.
A sampled sinusoid may be written as:

where f is the signal frequency, fs is the sampling frequency, 􀀀 is the phase and A is the
amplitude of the signal.
PROCEDURE:-

1. Open MATLAB

2. Open new M-file


3. Type the program

4. Save in current directory

5. Compile and Run the program

6. For the output see command window\ Figure window


PROGRAM:-
%unit impulse function%
clc;
clear all;
close all;
t=-10:1:10;
x=(t==0);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('unit impulse function');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit impulse discreat function');
%unit step function%
clc;
clear all;
close all;
N=100;
t=1:100;
x=ones(1,N);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('unit step function');
subplot(2,1,2);

stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit step discreat function');
%unit ramp function%
%unit ramp function%
clc;
clear all;
close all;
t=0:20;
x=t;
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('unit ramp function');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('unit ramp discreat function');
%sinusoidal function%
clc;
clear all;
close all;
t=0:0.01:2;
x=sin(2*pi*t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('sinusoidal signal');
subplot(2,1,2);

stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('sinusoidal sequence');
%square function%
clc;
clear all;
close all;
t=0:0.01:2;
x=square(2*pi*t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('square signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('square sequence');
%sawtooth function%
clc;
clear all;
close all;
t=0:0.01:2;
x=sawtooth(2*pi*5*t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('sawtooth signal');
subplot(2,1,2);
stem(t,x,'r');

xlabel('time');
ylabel('amplitude');
title('sawtooth sequence');
%trianguler function%
clc;
clear all;
close all;
t=0:0.01:2;
x=sawtooth(2*pi*5*t,0.5);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('trianguler signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');
ylabel('amplitude');
title('trianguler sequence');
%sinc function%
clc;
clear all;
close all;
t=linspace(-5,5);
x=sinc(t);
subplot(2,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('sinc signal');
subplot(2,1,2);
stem(t,x,'r');
xlabel('time');

ylabel('amplitude');
title('sinc sequence');
unit impulse function

You might also like