Please help with the following Matlab code for Signals and systems. Please keep
ID: 2267558 • Letter: P
Question
Please help with the following Matlab code for Signals and systems. Please keep it simple, and no complicated coding.
~~~~
First compute a vector representing time from 0 to 10 seconds in about 500 steps. Use this to compute a complex exponential with a period of 2 seconds, and a decay rate that reduces
the signal level at 10 seconds to half level to half of its original value. What sigma and f did you use?
You can assume the phase angle theta is zero. If your complex exponential is y, plot
>> plot(y);
What is matlab doing here?
Then Use the real() and imag() matlab functions to extract the real and imaginary part of the complex exponential, and plot them as a function of time.
Then Use the abs() and angle() functions to plot the magnitude and phase angle of the complex exponential. Scale the angle() plot by dividing it by 2*pi so that it fits well on the
same plot as the abs() plot (i.e. plot the angle in cycles, instead of radians).
~~~~~
This is the code i have so far, but not sure about the expo because I keep getting a circle....
t = 0:.005:10;
z = exp(j*2*pi*-t);
real(z);
imag(z);
figure(1)
plot(z);
Explanation / Answer
% Following MATLAB code will give you all answers, all lines are commented.
% EXPONENTIAL SIGNAL
clc;
clear all;
% First compute a vector representing time from 0 to 10 seconds in about 500 steps.
t = 0: 10/500:10;
w = 2 * pi * 0.5; % freq = 2 so t = 0.5
% Use this to compute a complex exponential with a period of 2 seconds, and a decay rate that reduces
% the signal level at 10 seconds to half level to half of its original value.
s = exp(- 1j *w*t); % amplitude = 1
plot (s)
title (' Exponential signal');
figure
plot (real(s)); % Real of s is cos( wt)
title (' Real term of Exponential signal');
figure
plot(imag(s));
title (' Imaginary term of Exponential signal');
% Imaginary part of s is sin wt
% s signal contains both cos wt + j sin wt so combination of both is a
% circle.
mag = abs (s);
title (' Abs term of Exponential signal');
figure
plot (mag);
title (' Magnitude of Exponential signal');
% magnitude ia 1
figure
ang = angle(s);
title ('Angle of Exponential signal');
% for angle variation , see figure
plot(ang);
angincycle = ang / (2- pi) ;
figure
plot (angincycle)
title (' Angle in Radians of Exponential signal');