Tag Archives: MATLAB

Discrete-Time Signals and System Properties

First, a comparison between Discrete-Time and Digital signals:

The independent variable (most commonly time) is represented by a sequence of numbers of a fixed interval. Both the independent variable and dependent variable are represented by a sequence of numbers of a fixed interval. 

Discrete-Time and Digital signal examples are shown below:

Discrete-Time Systems and Digital Systems are defined by their inputs and outputs being both either Discrete-Time Signals or Digital Signals.

Discrete-Time Signals

Discrete-Time Signal x[x] is sequence for all integers n.

  Unit Sample Sequence:
𝜹[n]: 1 at n=0, 0 otherwise.  
   Unit Step:
u[n] = 1 at n>=0, 0 otherwise.


Any sequence: x[n] = a1* 𝜹[n-1] + a2* 𝜹[n-2]+…
where a1, a2 are magnitude at integer n.

Exponential & Sinusoidal Sequences

Exponential sequence: x[n] = A 𝞪n
                                                 where 𝞪 is complex, x[n] = |A|ej𝜙 |𝞪|e0n=|A||𝞪|n ej(ω0n+𝜙)
                                                                                                     = |A||𝞪|n(cos(ω0n+𝜙)+j sin(ω0n+𝜙))
                Complex and sinusoidal: -𝝅< ω0< 𝝅 or 0< ω0< 2𝝅.

                                                Exponential sequences for given 𝞪 (complex 𝞪 left, real 𝞪 right):

Periodicity:        x[n] = x[n+N],  for all n. (definition). Period = N.
                                Sinusoid: x[n] = A cos(ω0n+𝜙) = A cos (ω0n+ ω0N+ 𝜙)
                                                Test: ω0N = 2𝝅k,                            (k is integer)

                                Exponential: x[n] = e0(n+N) = e0n,
                                                Test: ω0N = 2𝝅k,                            (k is integer)

System Properties

                                  System: Applied transformation y[n] = T{x[n]}

Memoryless Systems:

                                Output y[nx] is only dependent on input x[nx] where the same index nx is used for both (no time delay or advance).

Linear Systems:               Adherence to superposition. The additive property and scaling property.

Additive property:         Where y1[n] = T{x1[n]} and y2[n] = T{x2[n]},
y2[n] + y1[n] = T{x1[n]+ x2[n]}.

Scaling property:            T{a.x[n]} = a.y[n]           

Time-Invariant Systems:

                                Time shift of input causes equal time shift of output. T{x[n-M]} = y[n-M]


                                The system is causal if output y[n] is only dependent on x[n+M] where M<=0.


                                Input x[n] and Output y[n] of system reach a maximum of a number less than infinity. Must hold for all values of n.

Linear Time-Invariant Systems

                                Two Properties: Linear & Time-Invariant follows:

                “Response” hk[n] describes how system behaves to impulse 𝜹[n-k] occurring at n = k.

  • Convolution Sum: y[n] = x[n]*h[n].

Performing Discrete-Time convolution sum:

  1. Identify bounds of x[k] (where x[k] is non-zero) asN1 and N2.
  2. Determine expression for x[k]h[n-k].
  3. Solve for

General solution for exponential (else use tables):

Graphical solution: superposition of responses hk[n] for corresponding input x[n].

LTI System Properties

As LTI systems are described by convolution…

LTI is commutative: x[n]*h[n] = h[n]*x[n].

                                … is additive: x[n]*(h1[n]+h2[n]) = x[n]*h1[n] + x[n]*h2[n].

                                … is associative: (x[n]*h1[n])*h2[n] = x[n]*(h1[n]*h2[n])

                LTI is stable if the sum of impulse responses

                                … is causal if h[n] = 0 for n<0                  (causality definition).

Finite-duration Impulse response (FIR) systems:

                Impulse response h[n] has limited non-zero samples. Simple to determine stability (above).

Infinite-duration impulse response (IIR) systems:

                Example: Bh=

If a<1, Bh is stable and (using geom. series) =

Delay on impulse response: h[n] = sequence*delay = (𝜹[n+1]- 𝜹[n])* 𝜹[n-1] = 𝜹[n] – 𝜹[n-1].



Methods of Calculation for Signal Envelope

The envelope of a signal is an important concept. When a signal is modulated, meaning that information is combined with or embedded in a carrier signal, the envelope follows the shape of the signal on it’s upper and lower most edges.

There are a number of methods for calculating an envelope. When given an in-phase and quadrature signal, the envelope is defined as:

E = sqrt(I^2  + Q^2).

This envelope, if plotted will contain the exact upper or lower edge of the signal. An exact envelope may be sought, depending on the level of detail required for the application.

Here, this data was collected as a return from a fiber laser source. We seek to identify this section of the data to determine if the return signal fits the description out of a number of choices. The exact envelope using the above formula is less useful for the application.

The MATLAB formula is used to calculate the envelope:

[upI, lowI] = envelope(I,x,’peak’);

And this is plotted below with the I and Q signals:


Here are two envelopes depicted without the signal shown. By selecting the range of interpolation, this envelope can be smoother. Typically it is less desirable for an envelope to contain so many carrier signals, as is the following where x=1000, the range of interpolation.


Further methods involving the use of filters may also be of consideration. Below, the I and Q signals are taken through a bandpass filter (to ensure that the data is from the desired frequency range) and finally a lowpass filter is applied to the envelope to remove higher frequency oscillation.


Sinusoidal and Exponential Sequences, Periodicity of Sequences

Continuing our discussion on discrete-time sequences, we now come to define exponential and sinusoidal sequences. The general formula for a discrete-time exponential sequence is as follows:

x[n] = Aα^n.

This exponential behaves differently according to the value of α. If the sequence starts at n=0, the formula is as follows:

x[n] = Aα^n * u[n].


If α is a complex number, the exponential function exhibits newer characteristics. The envelope of the exponential is |α|. If |α| < 1, the system is decaying. If |α|> 1, the system is growing.


When α is complex, the sequence may be analyzed as follows, using the definition of Euler’s formula to express a complex relationship as a magnitude and phase difference.

Captu56 ma

Where ω0 is the frequency and φ is the phase, for n number of samples, a complex exponential sequence of form Ae^jw0n may be considered as a sinusoidal sequence for a set of frequencies in an interval of 2π.

A sinusoidal sequence is defined as follows:

x[n] = Acos(ω0*n + φ), for all n, and A, φ are real constants.

Periodicity for discrete-time signals means that the sequence will repeat itself for a certain delay, N.

x[n] = x[n+N] : system is periodic.

t = (-5:1:15)’;

impulse = t==0;
unitstep = t>=0;
Alpha1 = -0.5;
Alpha2 = 0.5;
Alpha3 = 2.5;
Alpha4 = -2.5;
cAlpha1 = -0.5 – 0.5i;
cAlpha2 = 0.5 + 0.5i;
cAlpha3 = 2.5 -2.5i;
cAlpha4 = -2.5 + 2.5i;
A = 1;

Exp1 = A.*unitstep.*Alpha1.^t;
Exp2 = A.*unitstep.*Alpha2.^t;
Exp3 = A.*unitstep.*Alpha3.^t;
Exp4 = A.*unitstep.*Alpha4.^t;

cExp1 = A.*unitstep.*cAlpha1.^t;
cExp2 = A.*unitstep.*cAlpha2.^t;
cExp3 = A.*unitstep.*cAlpha3.^t;
cExp4 = A.*unitstep.*cAlpha4.^t;

stem(t, impulse)

stem(t, unitstep)
title(‘Unit Step’)
stem(t, cExp1)
title(‘Exponential: alpha = -0.5 – 0.5i’)

stem(t, cExp2)
title(‘Exponential: alpha = 0.5 + 0.5i’)

stem(t, cExp3)
title(‘Exponential: alpha = 2.5 -2.5i’)

stem(t, cExp4)
title(‘Exponential: alpha = -2.5 + 2.5i’)
stem(t, Exp1)
title(‘Exponential: alpha = -0.5’)

stem(t, Exp2)
title(‘Exponential: alpha = 0.5’)

stem(t, Exp3)
title(‘Exponential: alpha = 2.5’)

stem(t, Exp4)
title(‘Exponential: alpha = -2.5’)



Discrete-Time Impulse and Unit Step Functions

Discrete-Time Signals are understood as a set or sequence of numbers. These sequences possess magnitudes or values at a given index.

One mark of Discrete-Time Signals is that the index value is an integer. Thus, the sequence will have a magnitude or value for a whole number index such as -5, -4, 0, 6, 10000, etc.

A discrete-time signal represented as a sequence of numbers takes the following form:

x[n] = {x[n]},          -∞ < n < ∞,

where n is any real integer (the index).

An analog representation describes values of a signal at time nT, where T is the sampling period. The sampling frequency is the inverse of the sampling period.

x[n] = X_a(nT),      -∞ < n < ∞.


Common Sequences

Both a very simple and important sequence is the unit sample sequence, “discrete time impulse” or simply “impulse,” equal to 1 only at zero and equal to zero otherwise.


The discrete time impulse is used to describe an entire system using a delayed impulse. An entire sequence may also be shifted or delayed using the following relation:

y[n] = x[n – n0],

where n0 is an integer (which is the increment of indices by which the system is delayed. The impulse function delayed to any index and multiplied by the value of the system at that index can describe any discrete-time system. The general formula for this relationship is,


The unit step sequence is related to the unit impulse. The unit step sequence is a set of numbers that is equal to zero for all numbers less than zero and equal to one for numbers equal and greater than zero.


The unit step sequence is therefore equal to a sequence of delta impulses with a zero and greater delay.

u[n] = δ[n] + δ[n-1] + δ[n-2] + . . .


The unit impulse can also be represented by unit step functions:

δ[n] = u[n] – u[n-1].

Below I’ve plotted both the impulse and unit step function in matlab.


t = (-10:1:10)';

impulse = t==0;
unitstep = t>=0;

stem(t, impulse)
stem(t, unitstep)
title('Unit Step')



Image Resolution

Consider that we are interested in building an optical sensor. This sensor contains a number of pixels, which is dependent on the size of the sensor. The sensor has two dimensions, horizontal and vertical. Knowing the size of the pixels, we will be able to find the total number of pixels on this sensor.

The horizontal field of view, HFOV is the total angle of view normal from the sensor. The effective focal length, EFL of the sensor is then:

Effective Focal Length: EFL = V / (tan(HFOV/2)),

where V is the vertical sensor size in (in meters, not in number of pixels) and HFOV is the horizontal field of view. Horizontal field of view as an angled is halved to account that HFOV extends to both sizes of the normal of the sensor.

The system resolution using the Kell Factor: R = 1000 * KellFactor * (1 / (PixelSize)),

where the Pixel size is typically given and the Kell factor, less than 1 will approximate a best real case result and accounts for aberrations and other potential issues.

Angular resolution: AR = R * EFL / 1000,

where R is the resolution using the Kell factor and EFL is the effective focal length. It is possible to compute the angular resolution using either pixels per millimeter or cycles per millimeter, however one would need to be consistent with units.

Minimum field of view: Δl = 1.22 * f * λ / D,

which was used previously for the calculation of the spatial resolution of a microscope. The minimum field of view is exactly a different wording for the minimum spatial resolution, or minimum size resolvable.

Below is a MATLAB program that computed these parameters, while sweeping the diameter of the lens aperture. The wavelength admittedly may not be appropriate for a microscope, but let’s say that you are looking for something in the infrared spectrum. Maybe you are trying to view some tiny laser beams that will be used in the telecom industry at 1550 nanometer.

Pixel size: 3 um. HFOV: 4 degrees. Sensor size: 8.9mm x 11.84mm.


Optical System Design using MATLAB

Previously featured was an article that derived a matrix formation of an equation for a thick lens. This matrix equation, it was said can be used to build a variety of optical systems. This will be undertaken using MATLAB. One of the great parts of using a matrix formula in MATLAB is that essentially any known parameter in the optical system can not only be altered directly, but a parameter sweep can be used to see how the parameter will effect the system. Parameters that can be altered include radius of curvature in the lens, thickness of the lens or distance between two lenses, wavelength, incidence angle, refractive indexes and more. You could also have MATLAB solve for a parameter such as the radius of curvature, given a desired angle. All of these parameters can be varied and the results can be plotted.


Matrix Formation for Thick Lens Equation

The matrix equation for the thick lens is modeled below:




  • nt2 is the refractive index beyond surface 2
  • αt2 is the angle of the exiting or transmitted ray
  • Yt2 is the height of the transmitted ray
  • D2 is the power of curvature of surface 2
  • D1 is the power of curvature of surface 1
  • R1 is the radius of curvature of surface 1
  • R2 is the radius of curvature of surface 2
  • d1 is the thickness of the lens or distance between surface 1 and 2
  • ni is the refractive index before surface 1
  • αi is the angle of the incident ray
  • Yi1 is the height of the incident ray

The following plots show a parameter sweep on an number of these variables. The following attachment includes the code that was used for these calculations and plots: optics1hw


Review of Fourier Series

The French mathematician Fourier discovered that any periodic waveform can be expressed as a series of harmonically related sinusoids.

Any periodic waveform can be expressed as the following:


The first term a0/2 is the constant DC or average component of f(t). The terms with coefficients a1 and b1 represent the fundamental frequency components of f(t). Coefficients a2 and b2 are the second harmonic components at frequency 2w. The frequency doubling on the second order harmonic is computed as a result of the multiplication of sinusoids.


In order to determine the coefficients of a harmonic series ai and bi, multiply both sides of the above formula by 2sin(2wt). In this case for simplicity, let w = 1.


Next, integrate from zero to 2*pi.


The following relations are then found:


The Fourier series are often expressed in exponential form:


The MATLAB function int(f,t,a,b) is often a useful tool, where f is the function, t is the symbolic variable, and a and b are the bounds of integration.




Random Signal Analyzer – MATLAB

ECE457 Senior Design
November 2019
Michael Benker

Random Signal Analyzer

The following MATLAB program is designed to create a random signal and analyze statistical properties. The applications for this are a current senior design project and the code may eventually be implemented in a project that involves a sound level analysis program on a microcontroller.



MATLAB Data Analysis – Senior Design Project Component

ECE457 – Senior Design Project, Professor Dr. Fortier
October 2019
Michael Benker
MATLAB Data Analysis


The following code was one component of my current Senior Design Project assignment, which will involve the creation of a device known as the “Audio Awareness Enabler.” More information relating to this project is sure to follow in the future. For now, let us take a look at the following MATLAB code, which takes excel files of data and calculates the averages and standard deviations and then plots a Gaussian normal plot. Soon, this code will be modified to be able to determine whether a set of data will fall into the “ambient” range or one of the three interrupt levels. It will also eventually seek to create a formula that will determine whether a set of data is in the interrupt zone based on the ambient level.

See the pdf file: ece457p9v002


Data at one location:


Next location:


I-Q Demodulation for Radar Cross Section Measurements

RF/Photonics Lab at UMASS Dartmouth, Advisor: Professor Dr. Yifei Li
October 2019
Michael Benker
RCS/ISAR Data Acquisition


Of critical importance to attaining an RCS measurement is the doppler shift, a change in return frequency that results in the movement of an object. I-Q demodulation is useful for attaining this measurement, producing the difference as an output signal when supplied two signals of different frequencies. The following MATLAB program utilizes a set of data acquired using an oscilloscope to test a demodulator. This is part of a project being undertaken at the UMASS Dartmouth RF/Photonics Lab. To view a published version of the code: rcs20190925.