Lab 3 Final.

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Department of Computer Engineering

Digital Signal Processing

Course Instructor:

Lab Engineer:

Semester

LAB EXPERIMENT # 03
Generation of Continuous and Discrete time Exponential Signals in MATLAB

OBJECTIVE:

To Represent the Exponential Signals & Sequences in MATLAB.

EXPONENTIAL SIGNALS:

In mathematics, the exponential function is the function ex, where e is the number (approximately
2.718281828) such that the function ex is its own derivative. The exponential function is used to
model a relationship
in which a constant change in the independent variable gives the same proportional change (i.e.,
percentage increase or decrease) in the dependent variable. The function is often written as exp(x),
especially when it is impractical to write the independent variable as a superscript. The exponential
function is widely used in physics, chemistry, and mathematics.

The graph of y = ex is upward-sloping and increases faster as x increases. The graph alwayslies above
the x-axis but can get arbitrarily close to it for negative x. So, we obtain converging graph for negative
values of x and diverging graph for positive values of x.

Its most basic form as function of time (t) is:

y(t)=Ae-(at)
OR
y(t)=Ae(at)

MATLAB CODE FOR IMPLEMENTATION:

1. Exponential signal & sequences implementation.

MATLAB CODE OUTPUT


2. Subplot in Matlab:

H = SUBPLOT(m,n,p), or SUBPLOT(mnp), breaks the Figure window into an m-by-n matrix of


small axes, selects the p-th axes for the current plot, and returns the axes handle. The axes are counted
along the top row of the Figure window, then the second row, etc.

%%Subplotting or Plotting of graphs in different platforms at a single tab

%%assigning values to x-axis x = 1:0.3:40;

%%assigning values to y-axis y=sin(x);


y1=cos(x);
y2=tan(x);
subplot(311)
plot(x,y,'b') grid on
xlabel('Time')
ylabel('sin(x)')
title('plot
of three graphs"')

subplot(312) plot(x,y1,'r')
grid on xlabel('Time') ylabel('cos(x)')
title('graph of time vs cos(x)')

subplot(313) plot(x,y2,'m')
grid on xlabel('Time')
ylabel('tan(x)')
title('graph of time vs tan(x)')
%%end

3. Finding the polar/rectangular form of a complex number:

To find the polar/rectangular form of complex number we use the Matlab command:

CART2POL Transform Cartesian to polar coordinates. [TH,R] = CART2POL(X,Y) transforms


corresponding elements of data stored in Cartesian coordinates X,Y to polar coordinates (angle TH
and radius R). The arrays X and Y must be the same size (or either can be scalar). TH is returned in
radians.

Let z= x+ yj

Now to convert to polar form the Matlab code is :


x=input('put the value of real part: '); y=input('put
the value of imaginary part: ');
%%x and y are real and imainary parts of the cartesian eq.
%%cartesian eq. a=x+y*i;

%%formula to find the magnitude


z_magnitude= sqrt(x^2 + y^2)

%%for angle in radians


z_radian=cart2pol(2,3)

%%for angle in degree z_degree=z_radian*(180/pi)

PRACTICE QUESTIONS

1. Plot the following function x(t)= Ceat Lets c>0 and draw for a<0 and a>0. Code: Code:
Graph:
2. Convert any number from polar to Cartesian form using Matlab code

3. Draw the following signal x(t)= 4e-2tcos(6t-60o). [First plot both the functions individually then
draw the plot of their product in the third graph using subplot]
4. Plot the Even and Odd Part of the signal x(t)= e-at for a>0.

Code:
5. clc
6. clear all
7. close all
8. a = 1;
9. t = -5:0.01:5;
10. xt = exp(-a * t); % x(t)
11. xnegt = exp(-a * (-t)); % x(-t)
12. % Even part of the signal
13. x_even = (xt + xnegt) / 2;
14. % Odd part of the signal
15. x_odd = (xt - xnegt) / 2;
16. % Plot the original signal
17. subplot(3, 1, 1);
18. plot(t, xt, 'b', 'LineWidth', 1.5);
19. title('Original Signal x(t) = e^{-at}');
20. xlabel('Time (t)');
21. ylabel('x(t)');
22. grid on;
23. % Plot the even part
24. subplot(3, 1, 2);
25. plot(t, x_even, 'r', 'LineWidth', 1.5);
26. title('Even Part of the Signal');
27. xlabel('Time (t)');
28. ylabel('x(t)');
29. grid on;
30. % Plot the odd part
31. subplot(3, 1, 3);
32. plot(t, x_odd, 'g', 'LineWidth', 1.5);
33. title('Odd Part of the Signal');
34. xlabel('Time (t)');
35. ylabel('x_{odd}(t)');
36. grid on;

Graph:

Rubrics:

Theoretical Setup Troubleshooting Completeness Total Aggregate


concepts preparation

You might also like