(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Part 1== | ==Part 1== | ||
+ | |||
+ | '''Changing a Periodic Continuous Time Signal to a Non-Periodic Discrete Time Signal''' | ||
+ | |||
One can take a signal that would be periodic in continuous time and turn it into a signal that is <b>not</b> periodic in discrete time. Consider the continuous time signal <math>x(t)=sin(t)</math>. Plotting this signal yields a smooth waveform that repeats itself with period <math>T=2\pi</math>. | One can take a signal that would be periodic in continuous time and turn it into a signal that is <b>not</b> periodic in discrete time. Consider the continuous time signal <math>x(t)=sin(t)</math>. Plotting this signal yields a smooth waveform that repeats itself with period <math>T=2\pi</math>. | ||
− | [[Image:hw2a1a_blaskows_ECE301Fall2008mboutin.jpg|frame|center|The continuous-time signal <math>x(t)=sin(t)</math> is periodic.]] | + | [[Image:hw2a1a_blaskows_ECE301Fall2008mboutin.jpg|300px|frame|center|The continuous-time signal <math>x(t)=sin(t)</math> is periodic.]] |
Sampling this signal at every integer time yields something altogether different. | Sampling this signal at every integer time yields something altogether different. | ||
− | [[Image:hw2a1b_blaskows_ECE301Fall2008mboutin.jpg|frame|center | + | [[Image:hw2a1b_blaskows_ECE301Fall2008mboutin.jpg|300px|frame|center|Sampling the continuous-time signal <math>x(t)=sin(t)</math> at integer times yields something like this. Note that the new discrete-time function <math>x[n]=sin(n)</math> is not periodic. Here we have shown five cycles of the formerly-periodic continuous time function.]] |
The new discrete time function looks like this on its own. | The new discrete time function looks like this on its own. | ||
− | [[Image:hw2a1c_blaskows_ECE301Fall2008mboutin.jpg|frame|center|300px|The | + | [[Image:hw2a1c_blaskows_ECE301Fall2008mboutin.jpg|300px|frame|center|The non-periodic discrete-time function <math>x[n]=sin(n)</math>.]] |
+ | |||
+ | For the signal to be periodic, there must exist an integer N such that <math>x[n]=x[n+N]</math>. For the signal defined as it is here, no such integer N exists. | ||
+ | |||
+ | |||
+ | '''Changing a Periodic Continuous Time Signal to a Periodic Discrete Time Signal''' | ||
+ | |||
+ | Suppose our sampling frequency, instead of being 1, was <math>\frac{\pi}{8}</math>. Then the newly sampled function overlaid with the continuous function would look something like | ||
+ | |||
+ | [[Image:hw2a1d_blaskows_ECE301Fall2008mboutin.jpg|300px|frame|center|The periodic discrete-time function <math>x[n]=sin(\frac{\pi}{8}n)</math> overlaid with its continuous time equivalent.]] | ||
+ | |||
+ | [[Image:hw2a1e_blaskows_ECE301Fall2008mboutin.jpg|300px|frame|center|The periodic discrete-time function <math>x[n]=sin(\frac{\pi}{8}n)</math>.]] | ||
+ | |||
+ | |||
+ | |||
+ | ==Part 2== | ||
+ | Consider the non-periodic function <math>f(t)=e^{-0.2t}*sin(10t)</math>. | ||
+ | |||
+ | [[Image:Nonperiodic_blaskows_ECE301Fall2008mboutin.jpg|frame|center|Non-periodic function <math>f(t)=e^{-0.2t}sin(10t)</math>.]] | ||
+ | |||
+ | If we run the following MATLAB code, we can create a signal with an arbitrary period. Presented here is a signal with period 5. | ||
+ | |||
+ | <pre> | ||
+ | %Set up the environment | ||
+ | clear | ||
+ | clc | ||
+ | |||
+ | %Define parameters for shifiting the function | ||
+ | delta=0.0001; %step size | ||
+ | period=5; %period of function to produce | ||
+ | nperiod=5; %number of periods to reproduce | ||
+ | |||
+ | %define an x-vector for the inputs to the function | ||
+ | x=-2*period:delta:(nperiod+2)*period; | ||
+ | |||
+ | %intermediate results -- this gets shifted and added as necessary | ||
+ | f=exp(-0.2.*x).*sin(10.*x); | ||
+ | |||
+ | %preallocate the y-vector for speed (MATLAB's suggestion) | ||
+ | y=zeros(size(x)); | ||
+ | |||
+ | %for each period we are to reproduce, add the appropriate section of the | ||
+ | %f-vector (shifted horizontally) to the output vector. | ||
+ | for count=1:period/delta:(nperiod+8)*period/delta | ||
+ | y(1,count:size(y,2))=y(1,count:size(y,2))+f(1,1:size(y,2)-count+1); | ||
+ | end | ||
+ | |||
+ | %plot the results | ||
+ | plot(x,y) | ||
+ | grid | ||
+ | axis([0,nperiod*period,min(y),max(y)]); | ||
+ | </pre> | ||
+ | |||
+ | Running this code produces this figure. | ||
+ | |||
+ | [[Image:HW2a1f_blaskows_ECE301Fall2008mboutin.jpg|frame|center|Non-periodic function <math>f(t)=e^{-0.2t}sin(10t)</math> shifted and added several times to produce a periodic function.]] |
Latest revision as of 10:07, 10 September 2008
Part 1
Changing a Periodic Continuous Time Signal to a Non-Periodic Discrete Time Signal
One can take a signal that would be periodic in continuous time and turn it into a signal that is not periodic in discrete time. Consider the continuous time signal $ x(t)=sin(t) $. Plotting this signal yields a smooth waveform that repeats itself with period $ T=2\pi $.
Sampling this signal at every integer time yields something altogether different.
The new discrete time function looks like this on its own.
For the signal to be periodic, there must exist an integer N such that $ x[n]=x[n+N] $. For the signal defined as it is here, no such integer N exists.
Changing a Periodic Continuous Time Signal to a Periodic Discrete Time Signal
Suppose our sampling frequency, instead of being 1, was $ \frac{\pi}{8} $. Then the newly sampled function overlaid with the continuous function would look something like
Part 2
Consider the non-periodic function $ f(t)=e^{-0.2t}*sin(10t) $.
If we run the following MATLAB code, we can create a signal with an arbitrary period. Presented here is a signal with period 5.
%Set up the environment clear clc %Define parameters for shifiting the function delta=0.0001; %step size period=5; %period of function to produce nperiod=5; %number of periods to reproduce %define an x-vector for the inputs to the function x=-2*period:delta:(nperiod+2)*period; %intermediate results -- this gets shifted and added as necessary f=exp(-0.2.*x).*sin(10.*x); %preallocate the y-vector for speed (MATLAB's suggestion) y=zeros(size(x)); %for each period we are to reproduce, add the appropriate section of the %f-vector (shifted horizontally) to the output vector. for count=1:period/delta:(nperiod+8)*period/delta y(1,count:size(y,2))=y(1,count:size(y,2))+f(1,1:size(y,2)-count+1); end %plot the results plot(x,y) grid axis([0,nperiod*period,min(y),max(y)]);
Running this code produces this figure.