Digital Communications

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 86

CHAPTER 1

INTRODUCTION

The digital modulation provides more information capacity, compatibility with digital data
services, higher data security, better quality communications, and quicker system availability.
Developers of communications systems face these constraints:
1. available bandwidth
2. permissible power
3. inherent noise level of the system
The RF spectrum must be shared, there are more users for that spectrum as demand for
communication services increases. Digital modulation schemes have greater capacity to convey
large amounts of information than analog modulation schemes.
1.1 Trading off simplicity and bandwidth
There is a fundamental tradeoff in communication systems. Simple hardware can be used in
transmitters and receivers to communicate information. However, this uses a lot of spectrum
which limits the number of users. Alternatively, more complex transmitters and receivers can be
used to transmit the same information over less bandwidth. The transition to more and more
spectrally efficient transmission techniques requires more and more complex hardware. Complex
hardware is difficult to design, test, and build. This tradeoff exists whether communication is
over air or wire, analog or digital.

Figure 1. The Fundamental Trade-off


1.2 Industry trends
Over the past few years a major transition has occurred from simple analog Amplitude
Modulation (AM) and Frequency/Phase Modulation (FM/PM) to new digital modulation
techniques. Examples of digital modulation include
• QPSK (Quadrature Phase Shift Keying)
• FSK (Frequency Shift Keying)
• MSK (Minimum Shift Keying)
• QAM (Quadrature Amplitude Modulation)

Figure 2. Trends in the Industry


Another layer of complexity in many new systems is multiplexing. Two principal types of
multiplexing (or “multiple access”) are TDMA (Time Division Multiple Access) and CDMA
(Code Division Multiple Access). These are two different ways to add diversity to signals
allowing different signals to be separated from one another
2.1 Transmitting information
To transmit a signal over the air, there are three main steps:
1. A pure carrier is generated at the transmitter.
2. The carrier is modulated with the information to be transmitted. Any reliably detectable
change in signal characteristics can carry information.
3. At the receiver the signal modifications or changes are detected and demodulated.
Figure 3. Transmitting Information (Analog or Digital)
2.2 Signal characteristics that can be modified
There are only three characteristics of a signal that can be changed over time: amplitude, phase
or frequency. However, phase and frequency are different ways to view or measure the same
signal change.

Figure 4. Signal Characteristics to Modify


In AM, the amplitude of a high-frequency carrier signal is varied in proportion to the
instantaneous amplitude of the modulating message signal. Frequency Modulation (FM) is the
most popular analog modulation technique used in mobile communications systems. In FM, the
amplitude of the modulating carrier is kept constant while its frequency is varied by the
modulating message signal. Amplitude and phase can be modulated simultaneously and
separately, but it is difficult to generate, and especially difficult to detect. Instead, in practical
systems the signal is separated into another set of independent components: I (In-phase) and Q
(Quadrature). These components are orthogonal and do not interfere with each other.
CHAPTER 2
DIGITAL MODULATION TYPES
This section covers the main digital modulation formats, their main applications, relative spectral
efficiencies and some variations of the main modulation types as used in practical systems.
Fortunately, there are a limited number of modulation types which form the building blocks of
any system.
2.1 Applications
This table covers the applications for different modulation formats in both wireless
communications and video.

Although this note focuses on wireless communications, video applications have also been
included in the table for completeness and because of their similarity to other wireless
communications.
3.1.1 Bit rate and symbol rate
To understand and compare different modulation format efficiencies, it is important to first
understand the difference between bit rate and symbol rate. The signal bandwidth for the
communications channel needed depends on the symbol rate, not on the bit rate.
Bit rate is the frequency of a system bit stream. Take, for example, a radio with an 8 bit sampler,
sampling at 10 kHz for voice. The bit rate, the basic bit stream rate in the radio, would be eight
bits multiplied by 10K samples per second, or 80 Kbits per second. (For the moment we will
ignore the extra bits required for synchronization, error correction, etc.)

Figure 10. Bit Rate and Symbol Rate


Figure 10 is an example of a state diagram of a Quadrature Phase Shift Keying (QPSK) signal.
The states can be mapped to zeros and ones. This is a common mapping, but it is not the only
one. Any mapping can be used. The symbol rate is the bit rate divided by the number of bits that
can be transmitted with each symbol. If one bit is transmitted per symbol, as with BPSK, then the
symbol rate would be the same as the bit rate of 80 Kbits per second. If two bits are transmitted
per symbol, as in QPSK, then the symbol rate would be half of the bit rate or 40 Kbits per
second. Symbol rate is sometimes called baud rate. Note that baud rate is not the same as bit rate.
These terms are often confused. If more bits can be sent with each symbol, then the same amount
of data can be sent in a narrower spectrum. This is why modulation formats that are more
complex and use a higher number of states can send the same information over a narrower piece
of the RF spectrum.
3.1.2 Spectrum (bandwidth) requirements
An example of how symbol rate influences spectrum requirements can be seen in eight-state
Phase Shift Keying (8PSK). It is a variation of PSK. There are eight possible states that the
signal can transition to at any time. The phase of the signal can take any of eight values at any
symbol time. Since 23 = 8, there are three bits per symbol. This means the symbol rate is one
third of the bit rate. This is relatively easy to decode.

3.1.3 Symbol clock


The symbol clock represents the frequency and exact timing of the transmission of the individual
symbols. At the symbol clock transitions, the transmitted carrier is at the correct I/Q (or
magnitude/phase) value to represent a specific symbol (a specific point in the constellation).
3.1 Amplitude Shift Keying

Amplitude-shift keying (ASK) is a form of amplitude modulation that represents digital data as
variations in the amplitude of a carrier wave. In an ASK system, the binary symbol 1 is
represented by transmitting a fixed-amplitude carrier wave and fixed frequency for a bit
duration of T seconds. If the signal value is 1 then the carrier signal will be transmitted;
otherwise, a signal value of 0 will be transmitted.
Any digital modulation scheme uses a finite number of distinct signals to represent digital data.
ASK uses a finite number of amplitudes, each assigned a unique pattern of binary digits.
Usually, each amplitude encodes an equal number of bits. Each pattern of bits forms
the symbol that is represented by the particular amplitude. The demodulator, which is designed
specifically for the symbol-set used by the modulator, determines the amplitude of the received
signal and maps it back to the symbol it represents, thus recovering the original
data. Frequency and phase of the carrier are kept constant.
Like AM, an ASK is also linear and sensitive to atmospheric noise, distortions, propagation
conditions on different routes in PSTN, etc. Both ASK modulation and demodulation processes
are relatively inexpensive. The ASK technique is also commonly used to transmit digital
data over optical fiber. For LED transmitters, binary 1 is represented by a short pulse of light
and binary 0 by the absence of light. Laser transmitters normally have a fixed "bias" current that
causes the device to emit a low light level. This low level represents binary 0, while a higher-
amplitude lightwave represents binary 1.
The simplest and most common form of ASK operates as a switch, using the presence of a
carrier wave to indicate a binary one and its absence to indicate a binary zero. This type of
modulation is called on-off keying (OOK), and is used at radio frequencies to transmit Morse
code (referred to as continuous wave operation),
More sophisticated encoding schemes have been developed which represent data in groups
using additional amplitude levels. For instance, a four-level encoding scheme can represent two
bits with each shift in amplitude; an eight-level scheme can represent three bits; and so on.
These forms of amplitude-shift keying require a high signal-to-noise ratio for their recovery, as
by their nature much of the signal is transmitted at reduced power.

ASK diagram
ASK system can be divided into three blocks. The first one represents the transmitter, the
second one is a linear model of the effects of the channel, the third one shows the structure of
the receiver. The following notation is used:
 ht(f) is the carrier signal for the transmission
 hc(f) is the impulse response of the channel
 n(t) is the noise introduced by the channel
 hr(f) is the filter at the receiver
 L is the number of levels that are used for transmission
 Ts is the time between the generation of two symbols
Different symbols are represented with different voltages. If the maximum allowed value for the
voltage is A, then all the possible values are in the range [−A, A] and they are given by:

Amplitude Shift Keying (ASK) is a type of Amplitude Modulation which represents the binary
data in the form of variations in the amplitude of a signal.Any modulated signal has a high
frequency carrier. The binary signal when ASK modulated, gives a zero value for Low input
while it gives the carrier output for High input. The following figure represents ASK
modulated waveform along with its input.

To find the process of obtaining this ASK modulated wave, let us learn about the working of the
ASK modulator.
ASK Modulator
The ASK modulator block diagram comprises of the carrier signal generator, the binary
sequence from the message signal and the band-limited filter. Following is the block diagram of
the ASK Modulator.

The carrier generator, sends a continuous high-frequency carrier. The binary sequence from the
message signal makes the unipolar input to be either High or Low. The high signal closes the
switch, allowing a carrier wave. Hence, the output will be the carrier signal at high input. When
there is low input, the switch opens, allowing no voltage to appear. Hence, the output will be
low.
The band-limiting filter, shapes the pulse depending upon the amplitude and phase
characteristics of the band-limiting filter or the pulse-shaping filter.

ASK Demodulator
There are two types of ASK Demodulation techniques. They are −

 Asynchronous ASK Demodulation/detection


 Synchronous ASK Demodulation/detection
The clock frequency at the transmitter when matches with the clock frequency at the receiver, it
is known as a Synchronous method, as the frequency gets synchronized. Otherwise, it is
known as Asynchronous.
Asynchronous ASK Demodulator
The Asynchronous ASK detector consists of a half-wave rectifier, a low pass filter, and a
comparator. Following is the block diagram for the same.

The modulated ASK signal is given to the half-wave rectifier, which delivers a positive half
output. The low pass filter suppresses the higher frequencies and gives an envelope detected
output from which the comparator delivers a digital output.

Synchronous ASK Demodulator


Synchronous ASK detector consists of a Square law detector, low pass filter, a comparator, and
a voltage limiter. Following is the block diagram for the same.
The ASK modulated input signal is given to the Square law detector. A square law detector is
one whose output voltage is proportional to the square of the amplitude modulated input
voltage. The low pass filter minimizes the higher frequencies. The comparator and the voltage
limiter help to get a clean digital output.

3.2 Phase Shift Keying


One of the simplest forms of digital modulation is binary or Bi-Phase Shift Keying (BPSK). One
application where this is used is for deep space telemetry. The phase of a constant amplitude
carrier signal moves between zero and 180 degrees. On an I and Q diagram, the I state has two
different values. There are two possible locations in the state diagram, so a binary one or zero
can be sent. The symbol rate is one bit per symbol.

Figure 12. Phase Shift Keying


A more common type of phase modulation is Quadrature Phase Shift Keying (QPSK). It is used
extensively in applications including CDMA (Code Division Multiple Access) cellular service,
wireless local loop, Iridium (a voice/data satellite system) and DVB-S (Digital Video
Broadcasting - Satellite). Quadrature means that the signal shifts between phase states which are
separated by 90 degrees. The signal shifts in increments of 90 degrees from 45 to 135, –45, or –
135 degrees. These points are chosen as they can be easily implemented using an I/Q modulator.
Only two I values and two Q values are needed and this gives two bits per symbol. There are
four states because 22 = 4. It is therefore a more bandwidth-efficient type of modulation than
BPSK, potentially twice as efficient.
Phase-shift keying (PSK) is a digital modulation process which conveys data by changing
(modulating) the phase of a constant frequency reference signal (the carrier wave). The
modulation is accomplished by varying the sine and cosine inputs at a precise time. It is widely
used for wireless LANs, RFID and Bluetooth communication.
Any digital modulation scheme uses a finite number of distinct signals to represent digital data.
PSK uses a finite number of phases, each assigned a unique pattern of binary digits. Usually,
each phase encodes an equal number of bits. Each pattern of bits forms the symbol that is
represented by the particular phase. The demodulator, which is designed specifically for the
symbol-set used by the modulator, determines the phase of the received signal and maps it back
to the symbol it represents, thus recovering the original data. This requires the receiver to be able
to compare the phase of the received signal to a reference signal – such a system is termed
coherent (and referred to as CPSK).
CPSK requires a complicated demodulator, because it must extract the reference wave from the
received signal and keep track of it, to compare each sample to. Alternatively, the phase shift of
each symbol sent can be measured with respect to the phase of the previous symbol sent.
Because the symbols are encoded in the difference in phase between successive samples, this is
called differential phase-shift keying (DPSK). DPSK can be significantly simpler to implement
than ordinary PSK, as it is a 'non-coherent' scheme, i.e. there is no need for the demodulator to
keep track of a reference wave. A trade-off is that it has more demodulation errors.
All convey data by changing some aspect of a base signal, the carrier wave (usually a sinusoid),
in response to a data signal. In the case of PSK, the phase is changed to represent the data signal.
There are two fundamental ways of utilizing the phase of a signal in this way:

By viewing the phase itself as conveying the information, in which case the demodulator must
have a reference signal to compare the received signal's phase against; or
By viewing the change in the phase as conveying information – differential schemes, some of
which do not need a reference carrier (to a certain extent).
A convenient method to represent PSK schemes is on a constellation diagram. This shows the
points in the complex plane where, in this context, the real and imaginary axes are termed the in-
phase and quadrature axes respectively due to their 90° separation. Such a representation on
perpendicular axes lends itself to straightforward implementation. The amplitude of each point
along the in-phase axis is used to modulate a cosine (or sine) wave and the amplitude along the
quadrature axis to modulate a sine (or cosine) wave. By convention, in-phase modulates cosine
and quadrature modulates sine.

In PSK, the constellation points chosen are usually positioned with uniform angular spacing
around a circle. This gives maximum phase-separation between adjacent points and thus the best
immunity to corruption. They are positioned on a circle so that they can all be transmitted with
the same energy. In this way, the moduli of the complex numbers they represent will be the same
and thus so will the amplitudes needed for the cosine and sine waves. Two common examples
are "binary phase-shift keying" (BPSK) which uses two phases, and "quadrature phase-shift
keying" (QPSK) which uses four phases, although any number of phases may be used. Since the
data to be conveyed are usually binary, the PSK scheme is usually designed with the number of
constellation points being a power of two.
Definitions[edit]
For determining error-rates mathematically, some definitions will be needed:

Q(x) will give the probability that a single sample taken from a random process with zero-mean
and unit-variance Gaussian probability density function will be greater or equal to x. It is a
scaled form of the complementary Gaussian error function:
The error rates quoted here are those in additive white Gaussian noise (AWGN). These error
rates are lower than those computed in fading channels, hence, are a good theoretical benchmark
to compare with.
Bit error rate
The bit error rate (BER) of PSK under additive white Gaussian noise (AWGN) can be calculated
as:[8]

Since there is only one bit per symbol, this is also the symbol error rate.
any number of phases may be used to construct a PSK constellation but 8-PSK is usually the
highest order PSK constellation deployed. With more than 8 phases, the error-rate becomes too
high and there are better, though more complex, modulations available such as quadrature
amplitude modulation (QAM). Although any number of phases may be used, the fact that the
constellation must usually deal with binary data means that the number of symbols is usually a
power of 2 to allow an integer number of bits per symbol.
For the general M-PSK there is no simple expression for the symbol-error probability if { M>4}
Unfortunately, it can only be obtained from
(Using Gray coding allows us to approximate the Lee distance of the errors as the Hamming
distance of the errors in the decoded bitstream, which is easier to implement in hardware.)

The graph on the left compares the bit-error rates of BPSK, QPSK (which are the same, as noted
above), 8-PSK and 16-PSK. It is seen that higher-order modulations exhibit higher error-rates; in
exchange however they deliver a higher raw data-rate.

Bounds on the error rates of various digital modulation schemes can be computed with
application of the union bound to the signal constellation.

The block diagram of Binary Phase Shift Keying consists of the balance modulator which has the
carrier sine wave as one input and the binary sequence as the other input. Following is the
diagrammatic representation.
The modulation of BPSK is done using a balance modulator, which multiplies the two signals
applied at the input. For a zero binary input, the phase will be 0° and for a high input, the phase
reversal is of 180°.
Following is the diagrammatic representation of BPSK Modulated output wave along with its
given input.

The output sine wave of the modulator will be the direct input carrier or the inverted (180° phase
shifted) input carrier, which is a function of the data signal.
BPSK Demodulator
The block diagram of BPSK demodulator consists of a mixer with local oscillator circuit, a
bandpass filter, a two-input detector circuit. The diagram is as follows.
By recovering the band-limited message signal, with the help of the mixer circuit and the band
pass filter, the first stage of demodulation gets completed. The base band signal which is band
limited is obtained and this signal is used to regenerate the binary message bit stream.
In the next stage of demodulation, the bit clock rate is needed at the detector circuit to produce
the original binary message signal. If the bit rate is a sub-multiple of the carrier frequency, then
the bit clock regeneration is simplified. To make the circuit easily understandable, a decision-
making circuit may also be inserted at the 2nd stage of detection.
3.3 Frequency Shift Keying

Frequency-shift keying (FSK) is a frequency modulation scheme in which digital information is


transmitted through discrete frequency changes of a carrier signal.[1] The technology is used for
communication systems such as telemetry, weather balloon radiosondes, caller ID, garage door
openers, and low frequency radio transmission in the VLF and ELF bands. The simplest FSK is
binary FSK (BFSK). BFSK uses a pair of discrete frequencies to transmit binary (0s and 1s)
information.[2] With this scheme, the "1" is called the mark frequency and the "0" is called the
space frequency.
Continuous-phase frequency-shift keying
Main article: continuous-phase frequency-shift keying
In principle FSK can be implemented by using completely independent free-running oscillators,
and switching between them at the beginning of each symbol period. In general, independent
oscillators will not be at the same phase and therefore the same amplitude at the switch-over
instant, causing sudden discontinuities in the transmitted signal.

In practice, many FSK transmitters use only a single oscillator, and the process of switching to a
different frequency at the beginning of each symbol period preserves the phase. The elimination
of discontinuities in the phase (and therefore elimination of sudden changes in amplitude)
reduces sideband power, reducing interference with neighboring channels.

Gaussian frequency-shift keying


Rather than directly modulating the frequency with the digital data symbols, "instantaneously"
changing the frequency at the beginning of each symbol period, Gaussian frequency-shift keying
(GFSK) filters the data pulses with a Gaussian filter to make the transitions smoother. This filter
has the advantage of reducing sideband power, reducing interference with neighboring channels,
at the cost of increasing intersymbol interference. It is used by DECT, Bluetooth,[5] Cypress
WirelessUSB, Nordic Semiconductor,[6] Texas Instruments LPRF, IEEE 802.15.4, Z-Wave and
Wavenis devices. For basic data rate Bluetooth the minimum deviation is 115 kHz.
A GFSK modulator differs from a simple frequency-shift keying modulator in that before the
baseband waveform (levels −1 and +1) goes into the FSK modulator, it is passed through a
Gaussian filter to make the transitions smoother so to limit its spectral width. Gaussian filtering
is a standard way for reducing spectral width; it is called "pulse shaping" in this application.

In ordinary non-filtered FSK, at a jump from −1 to +1 or +1 to −1, the modulated waveform


changes rapidly, which introduces large out-of-band spectrum. If the pulse is changed going
from −1 to +1 as −1, −0.98, −0.93, …, +0.93, +0.98, +1, and this smoother pulse is used to
determine the carrier frequency, the out-of-band spectrum will be reduced.[7]

Minimum-shift keying
Main article: Minimum-shift keying
Minimum frequency-shift keying or minimum-shift keying (MSK) is a particular spectrally
efficient form of coherent FSK. In MSK, the difference between the higher and lower frequency
is identical to half the bit rate. Consequently, the waveforms that represent a 0 and a 1 bit differ
by exactly half a carrier period. The maximum frequency deviation is δ = 0.25 fm, where fm is
the maximum modulating frequency. As a result, the modulation index m is 0.5. This is the
smallest FSK modulation index that can be chosen such that the waveforms for 0 and 1 are
orthogonal.

Gaussian minimum-shift keying


Main article: Gaussian minimum shift keying
A variant of MSK called Gaussian minimum-shift keying (GMSK) is used in the GSM mobile
phone standard.

Audio FSK
Audio frequency-shift keying (AFSK) is a modulation technique by which digital data is
represented by changes in the frequency (pitch) of an audio tone, yielding an encoded signal
suitable for transmission via radio or telephone. Normally, the transmitted audio alternates
between two tones: one, the "mark", represents a binary one; the other, the "space", represents a
binary zero.
AFSK differs from regular frequency-shift keying in performing the modulation at baseband
frequencies. In radio applications, the AFSK-modulated signal normally is being used to
modulate an RF carrier (using a conventional technique, such as AM or FM) for transmission.

AFSK is not always used for high-speed data communications, since it is far less efficient in both
power and bandwidth than most other modulation modes.[] In addition to its simplicity, however,
AFSK has the advantage that encoded signals will pass through AC-coupled links, including
most equipment originally designed to carry music or speech.

AFSK is used in the U.S.-based Emergency Alert System to notify stations of the type of
emergency, locations affected, and the time of issue without actually hearing the text of the alert.

Frequency modulation and phase modulation are closely related. A static frequency shift of +1
Hz means that the phase is constantly advancing at the rate of 360 degrees per second (2 π
rad/sec), relative to the phase of the unshifted signal.

FSK (Frequency Shift Keying) is used in many applications including cordless and paging
systems. Some of the cordless systems include DECT (Digital Enhanced Cordless Telephone)
and CT2 (Cordless Telephone 2). In FSK, the frequency of the carrier is changed as a function of
the modulating signal (data) being transmitted. Amplitude remains unchanged. In binary FSK
(BFSK or 2FSK), a “1” is represented by one frequency and a “0” is represented by another
frequency.
Frequency Shift Keying (FSK) is the digital modulation technique in which the frequency of
the carrier signal varies according to the digital signal changes. FSK is a scheme of frequency
modulation.
The output of a FSK modulated wave is high in frequency for a binary High input and is low in
frequency for a binary Low input. The binary 1s and 0s are called Mark and Space frequencies.
The following image is the diagrammatic representation of FSK modulated waveform along with
its input.

To find the process of obtaining this FSK modulated wave, let us know about the working of a
FSK modulator.
FSK Modulator
The FSK modulator block diagram comprises of two oscillators with a clock and the input binary
sequence. Following is its block diagram.
The two oscillators, producing a higher and a lower frequency signals, are connected to a switch
along with an internal clock. To avoid the abrupt phase discontinuities of the output waveform
during the transmission of the message, a clock is applied to both the oscillators, internally. The
binary input sequence is applied to the transmitter so as to choose the frequencies according to
the binary input.
FSK Demodulator
There are different methods for demodulating a FSK wave. The main methods of FSK detection
are asynchronous detector and synchronous detector. The synchronous detector is a coherent
one, while asynchronous detector is a non-coherent one.
Asynchronous FSK Detector
The block diagram of Asynchronous FSK detector consists of two band pass filters, two
envelope detectors, and a decision circuit. Following is the diagrammatic representation.
The FSK signal is passed through the two Band Pass Filters (BPFs), tuned
to Space and Mark frequencies. The output from these two BPFs look like ASK signal, which is
given to the envelope detector. The signal in each envelope detector is modulated
asynchronously.
The decision circuit chooses which output is more likely and selects it from any one of the
envelope detectors. It also re-shapes the waveform to a rectangular one.
Synchronous FSK Detector
The block diagram of Synchronous FSK detector consists of two mixers with local oscillator
circuits, two band pass filters and a decision circuit. Following is the diagrammatic
representation.
The FSK signal input is given to the two mixers with local oscillator circuits. These two are
connected to two band pass filters. These combinations act as demodulators and the decision
circuit chooses which output is more likely and selects it from any one of the detectors. The two
signals have a minimum frequency separation.
For both of the demodulators, the bandwidth of each of them depends on their bit rate. This
synchronous demodulator is a bit complex than asynchronous type demodulators.

Bit Error Rate (BER) for frequency shift keying with coherent demodulation
Following the request by Siti Naimah, this post discuss the bit error probability for coherent
demodulation of binary Frequency Shift Keying (BFSK) along with a small Matlab code snippet.
Using the definition provided in Sec 4.4.4 of [DIG-COMM-SKLAR]), in binary Frequency shift

keying (BFSK), the bits 0′s and 1′s are represented by signals and having frequencies

and respectively, i.e.

,
where
is the energy ,
is the symbol duration and
is an arbitrary phase (assume to be zero).

The two frequencies and are orthogonal, i.e.

and

Simple transmit-receive block diagram for binary frequency shift keying (FSK) can be as shown
below.

Figure: Block diagram of FSK modulation and coherent demodulation


For analyzing the bit error rate with coherent FSK demodulation, let us compare the
signaling waveform used by binary FSK when compared with binary PSK. The distance between
the energy of the signaling waveform for:
(a) binary phase shift keying (BPSK) is (uses antipodal signaling)
(b) binary frequency shift keying (BFSK) is (uses orthogonal signaling)
Figure: Orthogonal and antipodal signaling
Using similar mathematical formulation used for BPSK, but with the distance between the
signals reduced by half, the bit error probability for coherent binary frequency shift keying is

.
For obtaining the same bit error rate as BPSK, binary frequency shift keying requires around 3dB

more .

3.4 Quadrature phase-shift keying (QPSK)


Sometimes this is known as quadriphase PSK, 4-PSK, or 4-QAM. (Although the root concepts
of QPSK and 4-QAM are different, the resulting modulated radio waves are exactly the same.)
QPSK uses four points on the constellation diagram, equispaced around a circle. With four
phases, QPSK can encode two bits per symbol, shown in the diagram with Gray coding to
minimize the bit error rate (BER) – sometimes misperceived as twice the BER of BPSK.
The mathematical analysis shows that QPSK can be used either to double the data rate compared
with a BPSK system while maintaining the same bandwidth of the signal, or to maintain the
data-rate of BPSK but halving the bandwidth needed. In this latter case, the BER of QPSK
is exactly the same as the BER of BPSK – and deciding differently is a common confusion when
considering or describing QPSK. The transmitted carrier can undergo numbers of phase changes.
Given that radio communication channels are allocated by agencies such as the Federal
Communication Commission giving a prescribed (maximum) bandwidth, the advantage of
QPSK over BPSK becomes evident: QPSK transmits twice the data rate in a given bandwidth
compared to BPSK - at the same BER. The engineering penalty that is paid is that QPSK
transmitters and receivers are more complicated than the ones for BPSK. However, with
modern electronics technology, the penalty in cost is very moderate.
As with BPSK, there are phase ambiguity problems at the receiving end, and differentially
encoded QPSK is often used in practice.

Constellation diagram for QPSK with Gray coding. Each adjacent symbol only differs by one bit.
Implementation[edit]
The implementation of QPSK is more general than that of BPSK and also indicates the
implementation of higher-order PSK. Writing the symbols in the constellation diagram in terms
of the sine and cosine waves used to transmit them:

This yields the four phases π/4, 3π/4, 5π/4 and 7π/4 as needed.
This results in a two-dimensional signal space with unit basis functions
The first basis function is used as the in-phase component of the signal and the second as the
quadrature component of the signal.
Hence, the signal constellation consists of the signal-space 4 points

The factors of 1/2 indicate that the total power is split equally between the two carriers.
Comparing these basis functions with that for BPSK shows clearly how QPSK can be viewed as
two independent BPSK signals. Note that the signal-space points for BPSK do not need to split
the symbol (bit) energy over the two carriers in the scheme shown in the BPSK constellation
diagram.
QPSK systems can be implemented in a number of ways. An illustration of the major
components of the transmitter and receiver structure are shown below.

Conceptual transmitter structure for QPSK. The binary data stream is split into the in-phase and
quadrature-phase components. These are then separately modulated onto two orthogonal basis
functions. In this implementation, two sinusoids are used. Afterwards, the two signals are
superimposed, and the resulting signal is the QPSK signal. Note the use of polar non-return-to-
zero encoding. These encoders can be placed before for binary data source, but have been placed
after to illustrate the conceptual difference between digital and analog signals involved with
digital modulation.

Receiver structure for QPSK. The matched filters can be replaced with correlators. Each
detection device uses a reference threshold value to determine whether a 1 or 0 is detected.
Bit error rate of QPSK
Although QPSK can be viewed as a quaternary modulation, it is easier to see it as two
independently modulated quadrature carriers. With this interpretation, the even (or odd) bits are
used to modulate the in-phase component of the carrier, while the odd (or even) bits are used to
modulate the quadrature-phase component of the carrier. BPSK is used on both carriers and they
can be independently demodulated.
As a result, the probability of bit-error for QPSK is the same as for BPSK:

The modulated signal is shown below for a short segment of a random binary data-stream. The
two carrier waves are a cosine wave and a sine wave, as indicated by the signal-space analysis
above. Here, the odd-numbered bits have been assigned to the in-phase component and the even-
numbered bits to the quadrature component (taking the first bit as number 1). The total signal –
the sum of the two components – is shown at the bottom. Jumps in phase can be seen as the PSK
changes the phase on each component at the start of each bit-period. The topmost waveform
alone matches the description given for BPSK above.

Timing diagram for QPSK. The binary data stream is shown beneath the time axis. The two
signal components with their bit assignments are shown at the top, and the total combined signal
at the bottom. Note the abrupt changes in phase at some of the bit-period boundaries.

The binary data that is conveyed by this waveform is: 11000110.


 The odd bits, highlighted here, contribute to the in-phase component: 11000110
 The even bits, highlighted here, contribute to the quadrature-phase component: 11000110

Offset quadrature phase-shift keying (OQPSK) is a variant of phase-shift keying modulation


using four different values of the phase to transmit. It is sometimes called staggered quadrature
phase-shift keying (SQPSK).
Difference of the phase between QPSK and OQPSK
Taking four values of the phase (two bits) at a time to construct a QPSK symbol can allow the
phase of the signal to jump by as much as 180° at a time. When the signal is low-pass filtered (as
is typical in a transmitter), these phase-shifts result in large amplitude fluctuations, an
undesirable quality in communication systems. By offsetting the timing of the odd and even bits
by one bit-period, or half a symbol-period, the in-phase and quadrature components will never
change at the same time. In the constellation diagram shown on the right, it can be seen that this
will limit the phase-shift to no more than 90° at a time. This yields much lower amplitude
fluctuations than non-offset QPSK and is sometimes preferred in practice.
The picture on the right shows the difference in the behavior of the phase between ordinary
QPSK and OQPSK. It can be seen that in the first plot the phase can change by 180° at once,
while in OQPSK the changes are never greater than 90°.
The modulated signal is shown below for a short segment of a random binary data-stream. Note
the half symbol-period offset between the two component waves. The sudden phase-shifts occur
about twice as often as for QPSK (since the signals no longer change together), but they are less
severe. In other words, the magnitude of jumps is smaller in OQPSK when compared to QPSK
Signal doesn't pass through the origin, because only one bit of the symbol is changed at a time.

Timing diagram for offset-QPSK. The binary data stream is shown beneath the time axis. The
two signal components with their bit assignments are shown the top and the total, combined
signal at the bottom. Note the half-period offset between the two signal components.
π/4-QPSK[edit]
Dual constellation diagram for π/4-QPSK. This shows the two separate constellations with
identical Gray coding but rotated by 45° with respect to each other.

Transition scheme of the modulation symbols of the π/4-QPSK (signal constellation). No zero
crossings.

This variant of QPSK uses two identical constellations which are rotated by 45° ( radians,
hence the name) with respect to one another. Usually, either the even or odd symbols are used to
select points from one of the constellations and the other symbols select points from the other
constellation. This also reduces the phase-shifts from a maximum of 180°, but only to a

maximum of 135° and so the amplitude fluctuations of -QPSK are between OQPSK and
non-offset QPSK.
One property this modulation scheme possesses is that if the modulated signal is represented in
the complex domain, transitions between symbols never pass through 0. In other words, the
signal does not pass through the origin. This lowers the dynamical range of fluctuations in the
signal which is desirable when engineering communications signals.

On the other hand, -QPSK lends itself to easy demodulation and has been adopted for use
in, for example, TDMA cellular telephone systems.
The modulated signal is shown below for a short segment of a random binary data-stream. The
construction is the same as above for ordinary QPSK. Successive symbols are taken from the two
constellations shown in the diagram. Thus, the first symbol (1 1) is taken from the "blue"
constellation and the second symbol (0 0) is taken from the "green" constellation. Note that
magnitudes of the two component waves change as they switch between constellations, but the
total signal's magnitude remains constant (constant envelope). The phase-shifts are between
those of the two previous timing-diagrams.

Timing diagram for π/4-QPSK. The binary data stream is shown beneath the time axis. The two
signal components with their bit assignments are shown the top and the total, combined signal at
the bottom. Note that successive symbols are taken alternately from the two constellations,
starting with the "blue" one.
SOQPSK[edit]
The license-free shaped-offset QPSK (SOQPSK) is interoperable with Feher-patented QPSK
(FQPSK), in the sense that an integrate-and-dump offset QPSK detector produces the same
output no matter which kind of transmitter is used.[9]
These modulations carefully shape the I and Q waveforms such that they change very smoothly,
and the signal stays constant-amplitude even during signal transitions. (Rather than traveling
instantly from one symbol to another, or even linearly, it travels smoothly around the constant-
amplitude circle from one symbol to the next.)
The standard description of SOQPSK-TG involves ternary symbols
DPQPSK[edit]
Dual-polarization quadrature phase shift keying (DPQPSK) or dual-polarization QPSK -
involves the polarization multiplexing of two different QPSK signals, thus improving the
spectral efficiency by a factor of 2. This is a cost-effective alternative to utilizing 16-PSK,
instead of QPSK to double the spectral efficiency.
The second variation is differential modulation as used in differential QPSK (DQPSK) and
differential 16QAM (D16QAM). Differential means that the information is not carried by the
absolute state, it is carried by the transition between states. In some cases there are also
restrictions on allowable transitions. This occurs in π/ 4 DQPSK where the carrier trajectory does
not go through the origin. A DQPSK transmission system can transition from any symbol
position to any other symbol position. The π/ 4 DQPSK modulation format is widely used in
many applications including • cellular -NADC- IS-54 (North American digital cellular) -PDC
(Pacific Digital Cellular) • cordless -PHS (personal handyphone system) • trunked radio -TETRA
(Trans European Trunked Radio) The π/ 4 DQPSK modulation format uses two QPSK
constellations offset by 45 degrees (π/ 4 radians). Transitions must occur from one constellation
to the other. This guarantees that there is always a change in phase at each symbol, making clock
recovery easier. The data is encoded in the magnitude and direction of the phase shift, not in the
absolute position on the constellation. One advantage of π/ 4 DQPSK is that the signal trajectory
does not pass through the origin, thus simplifying transmitter design. Another is that π/ 4
DQPSK, with root raised cosine filtering, has better spectral efficiency than GMSK, the other
common cellular modulation type.
Figure 16. “Differential” Modulation

The Quadrature Phase Shift Keying (QPSK) is a variation of BPSK, and it is also a Double Side
Band Suppressed Carrier (DSBSC) modulation scheme, which sends two bits of digital
information at a time, called as bigits.

Instead of the conversion of digital bits into a series of digital stream, it converts them into bit
pairs. This decreases the data bit rate to half, which allows space for the other users.

QPSK Modulator

The QPSK Modulator uses a bit-splitter, two multipliers with local oscillator, a 2-bit serial to
parallel converter, and a summer circuit. Following is the block diagram for the same.
At the modulator’s input, the message signal’s even bits (i.e., 2nd bit, 4th bit, 6th bit, etc.) and odd
bits (i.e., 1st bit, 3rd bit, 5th bit, etc.) are separated by the bits splitter and are multiplied with the
same carrier to generate odd BPSK (called as PSKI) and even BPSK (called as PSKQ).
The PSKQ signal is anyhow phase shifted by 90° before being modulated.

The QPSK waveform for two-bits input is as follows, which shows the modulated result for
different instances of binary inputs.
QPSK Demodulator

The QPSK Demodulator uses two product demodulator circuits with local oscillator, two band
pass filters, two integrator circuits, and a 2-bit parallel to serial converter. Following is the
diagram for the same.
The two product detectors at the input of demodulator simultaneously demodulate the two
BPSK signals. The pair of bits are recovered here from the original data. These signals after
processing, are passed to the parallel to serial converter.

Differential phase-shift keying (DPSK)


Differential phase shift keying (DPSK) is a common form of phase modulation that conveys
data by changing the phase of the carrier wave. As mentioned for BPSK and QPSK there is an
ambiguity of phase if the constellation is rotated by some effect in the communications
channel through which the signal passes. This problem can be overcome by using the data
to change rather than set the phase.

For example, in differentially encoded BPSK a binary "1" may be transmitted by adding 180° to
the current phase and a binary "0" by adding 0° to the current phase. Another variant of DPSK
is Symmetric Differential Phase Shift keying, SDPSK, where encoding would be +90° for a "1"
and −90° for a "0".

In differentially encoded QPSK (DQPSK), the phase-shifts are 0°, 90°, 180°, −90°
corresponding to data "00", "01", "11", "10". This kind of encoding may be demodulated in the
same way as for non-differential PSK but the phase ambiguities can be ignored. Thus, each

received symbol is demodulated to one of the points in the constellation and


a comparator then computes the difference in phase between this received signal and the
preceding one. The difference encodes the data as described above. Symmetric differential
quadrature phase shift keying (SDQPSK) is like DQPSK, but encoding is symmetric, using
phase shift values of −135°, −45°, +45° and +135°.

The modulated signal is shown below for both DBPSK and DQPSK as described above. In the
figure, it is assumed that the signal starts with zero phase, and so there is a phase shift in both
signals at .
Timing diagram for DBPSK and DQPSK. The binary data stream is above the DBPSK signal.
The individual bits of the DBPSK signal are grouped into pairs for the DQPSK signal, which
only changes every Ts = 2Tb.

Analysis shows that differential encoding approximately doubles the error rate compared to
ordinary -PSK but this may be overcome by only a small increase . Furthermore, this analysis
(and the graphical results below) are based on a system in which the only corruption is additive
white Gaussian noise (AWGN). However, there will also be a physical channel between the
transmitter and receiver in the communication system. This channel will, in general, introduce
an unknown phase-shift to the PSK signal; in these cases the differential schemes can yield
a better error-rate than the ordinary schemes which rely on precise phase information.

One of the most popular applications of DPSK is the Bluetooth standard where -DQPSK and 8-
DPSK were implemented.

Demodulation[edit]
BER comparison between DBPSK, DQPSK and their non-differential forms using Gray coding
and operating in white noise

For a signal that has been differentially encoded, there is an obvious alternative method of
demodulation. Instead of demodulating as usual and ignoring carrier-phase ambiguity, the phase
between two successive received symbols is compared and used to determine what the data
must have been. When differential encoding is used in this manner, the scheme is known as
differential phase-shift keying (DPSK). Note that this is subtly different from just differentially
encoded PSK since, upon reception, the received symbols are not decoded one-by-one to
constellation points but are instead compared directly to one another.

Call the received symbol in the th timeslot and let it have phase . Assume without loss of
generality that the phase of the carrier wave is zero. Denote the additive white Gaussian
noise (AWGN) .

The decision variable for the nth symbol and the nth symbol is the phase difference between .
That is, if is projected onto , the decision is taken on the phase of the resultant complex
number:

In the absence of noise, the phase of this is , the phase-shift between the two received signals
which can be used to determine the data transmitted.

The probability of error for DPSK is difficult to calculate in general, but, in the case of DBPSK

which, when numerically evaluated, is only slightly worse than ordinary BPSK, particularly at
higher values.
Using DPSK avoids the need for possibly complex carrier-recovery schemes to provide an
accurate phase estimate and can be an attractive alternative to ordinary PSK.

In optical communications, the data can be modulated onto the phase of a laser in a differential
way. The modulation is a laser which emits a continuous wave, and a Mach–Zehnder
modulator which receives electrical binary data. For the case of BPSK, the laser transmits the
field unchanged for binary '1', and with reverse polarity for '0'. The demodulator consists of
a delay line interferometer which delays one bit, so two bits can be compared at one time. In
further processing, a photodiode is used to transform the optical field into an electric current, so
the information is changed back into its original state.

The bit-error rates of DBPSK and DQPSK are compared to their non-differential counterparts in
the graph to the right. The loss for using DBPSK is small enough compared to the complexity
reduction that it is often used in communications systems that would otherwise use BPSK. For
DQPSK though, the loss in performance compared to ordinary QPSK is larger and the system
designer must balance this against the reduction in complexity.

Example: Differentially encoded BPSK[edit]

Differential encoding/decoding system diagram

At the time-slot call the bit to be modulated , the differentially encoded bit and the
resulting modulated signal . Assume that the constellation diagram positions the symbols at ±1
(which is BPSK). The differential encoder produces:
BER comparison between BPSK and differentially encoded BPSK with Gray coding operating
in white noise

So only changes state (from binary "0" to binary "1" or from binary "1" to binary "0") if is a
binary "1". Otherwise it remains in its previous state. This is the description of differentially
encoded BPSK given above.

The received signal is demodulated to yield and then the differential decoder reverses the
encoding procedure and produces since binary subtraction is the same as binary addition.

Therefore, if and differ and if they are the same. Hence, if both and are inverted, will still
be decoded correctly. Thus, the 180° phase ambiguity does not matter.

Differential schemes for other PSK modulations may be devised along similar lines. The
waveforms for DPSK are the same as for differentially encoded PSK given above since the only
change between the two schemes is at the receiver.

The BER curve for this example is compared to ordinary BPSK on the right. As mentioned
above, whilst the error rate is approximately doubled, the increase needed in to overcome this is
small. The increase in required to overcome differential modulation in coded systems, however,
is larger – typically about 3 dB. The performance degradation is a result of noncoherent
transmission – in this case it refers to the fact that tracking of the phase is completely ignored.

In Differential Phase Shift Keying (DPSK) the phase of the modulated signal is shifted
relative to the previous signal element. No reference signal is considered here. The signal phase
follows the high or low state of the previous element. This DPSK technique doesn’t need a
reference oscillator.

The following figure represents the model waveform of DPSK.

It is seen from the above figure that, if the data bit is Low i.e., 0, then the phase of the signal is
not reversed, but continued as it was. If the data is a High i.e., 1, then the phase of the signal is
reversed, as with NRZI, invert on 1 (a form of differential encoding).

If we observe the above waveform, we can say that the High state represents an M in the
modulating signal and the Low state represents a W in the modulating signal.

DPSK Modulator

DPSK is a technique of BPSK, in which there is no reference phase signal. Here, the transmitted
signal itself can be used as a reference signal. Following is the diagram of DPSK Modulator.
DPSK encodes two distinct signals, i.e., the carrier and the modulating signal with 180° phase
shift each. The serial data input is given to the XNOR gate and the output is again fed back to
the other input through 1-bit delay. The output of the XNOR gate along with the carrier signal is
given to the balance modulator, to produce the DPSK modulated signal.

DPSK Demodulator

In DPSK demodulator, the phase of the reversed bit is compared with the phase of the previous
bit. Following is the block diagram of DPSK demodulator.

From the above figure, it is evident that the balance modulator is given the DPSK signal along
with 1-bit delay input. That signal is made to confine to lower frequencies with the help of LPF.
Then it is passed to a shaper circuit, which is a comparator or a Schmitt trigger circuit, to
recover the original binary data as the output.

Applications

ASK

In 1910, Reginald Fessenden invented a two-tone method of transmitting Morse code. Dots and
dashes were replaced with different tones of equal length.[10] The intent was to minimize
transmission time. Some early CW transmitters employed an arc converter that could not be
conveniently keyed. Instead of turning the arc on and off, the key slightly changed the
transmitter frequency in a technique known as the compensation-wave method.[11] The
compensation-wave was not used at the receiver. Spark transmitters used for this method
consumed a lot of bandwidth and caused interference, so it was discouraged by 1921.[12]
FSK

Most early telephone-line modems used audio frequency-shift keying (AFSK) to send and
receive data at rates up to about 1200 bits per second. The Bell 103 and Bell 202 modems used
this technique.[13] Even today, North American caller ID uses 1200 baud AFSK in the form of
the Bell 202 standard. Some early microcomputers used a specific form of AFSK modulation,
the Kansas City standard, to store data on audio cassettes[]. AFSK is still widely used in
amateur radio, as it allows data transmission through unmodified voiceband equipment.

AFSK is also used in the United States' Emergency Alert System to transmit warning
information[]. It is used at higher bitrates for Weathercopy used on Weatheradio by NOAA in
the U.S.

The CHU shortwave radio station in Ottawa, Ontario, Canada broadcasts an exclusive digital
time signal encoded using AFSK modulation.[]

Standards for use in Caller ID and remote metering

Frequency-shift keying (FSK) is commonly used over telephone lines for Caller ID (displaying
callers' numbers) and remote metering applications. There are several variations of this
technology.

European Telecommunications Standards Institute FSK

In some countries of Europe, the European Telecommunications Standards Institute (ETSI)


standards 200 778-1 and -2 – replacing 300 778-1 & -2 – allow 3 physical transport layers
(Telcordia Technologies (formerly Bellcore), British Telecom (BT) and Cable Communications
Association (CCA)), combined with 2 data formats Multiple Data Message Format (MDMF) &
Single Data Message Format (SDMF), plus the Dual-tone multi-frequency (DTMF) system and
a no-ring mode for meter-reading and the like. It's more of a recognition that the different types
exist than an attempt to define a single "standard".

Telcordia Technologies FSK

The Telcordia Technologies (formerly Bellcore) standard is used in the United States, Canada
(but see below), Australia, China, Hong Kong and Singapore. It sends the data after the first
ring tone and uses the 1200 bits per second Bell 202 tone modulation. The data may be sent in
SDMF – which includes the date, time and number – or in MDMF, which adds a NAME field.

British Telecom FSK

British Telecom (BT) in the United Kingdom developed their own standard, which wakes up
the display with a line reversal, then sends the data as CCITT v.23 modem tones in a format
similar to MDMF. It is used by BT, wireless networks like the late Ionica, and some cable
companies. Details are to be found in BT Supplier Information Notes (SINs) 227 and 242;
another useful document is Designing Caller Identification Delivery Using XR-2211 for BT
from the EXAR website.

Cable Communications Association FSK

The Cable Communications Association (CCA) of the United Kingdom developed their own
standard which sends the information after a short first ring, as either Bell 202 or V.23 tones.
They developed a new standard rather than change some "street boxes" (multiplexors) which
couldn't cope with the BT standard. The UK cable industry use a variety of switches: most are
Nortel DMS-100; some are System X; System Y; and Nokia DX220. Note that some of these
use the BT standard instead of the CCA one. The data format is similar to the BT one, but the
transport layer is more like Telcordia Technologies, so North American or European equipment
is more likely to detect it.

Application of phase-shift keying in underwater acoustic communication based on


orthogonal frequency division multiplexing

With the increase of of marine resource and underwater users, developing a high-bit-
rate underwater acoustic communication has become a hot topic. APSK (Amplitude and Phase-
shift Keying) is a modulation technique having high efficiency in spectrum utilization, it attracts
more and more attention in high-bit-rate underwater acoustic communication. Differential
APSK (DAPSK) is modulated using differential amplitude and phase code in time domain, and
it has higher bandwidth efficiency and be easier to realize the system than APSK. A
transmission system based on DAPSK modulation and OFDM is presented to solve the
problems of effectiveness and reliability in high-bit-rate underwater acoustic communication.
Simulation results show that the system using DAPSK modulation has a better performance
than those using APSK and QAM modulation.
CHAPTER
MATLAB

INTRODUCTION
What Is MATLAB?
MATLAB® is a high-performance language for technical computing. It integrates
computation, visualization, and programming in an easy-to-use environment where problems and
solutions are expressed in familiar mathematical notation. Typical uses include:
 Math and computation
 Algorithm development
 Modeling, simulation, and prototyping
 Data analysis, exploration, and visualization
 Scientific and engineering graphics
 Application development, including graphical user interface building
MATLAB is an interactive system whose basic data element is an array that does
not require dimensioning. This allows you to solve many technical computing problems,
especially those with matrix and vector formulations, in a fraction of the time it would take to
write a program in a scalar noninteractive language such as C or FORTRAN.

The name MATLAB stands for matrix laboratory. MATLAB was originally
written to provide easy access to matrix software developed by the LINPACK and EISPACK
projects. Today, MATLAB uses software developed by the LAPACK and ARPACK projects,
which together represent the state-of-the-art in software for matrix computation.
MATLAB has evolved over a period of years with input from many users. In
university environments, it is the standard instructional tool for introductory and advanced
courses in mathematics, engineering, and science. In industry, MATLAB is the tool of choice for
high-productivity research, development, and analysis.
MATLAB features a family of application-specific solutions called toolboxes.
Very important to most users of MATLAB, toolboxes allow you to learn and apply specialized
technology. Toolboxes are comprehensive collections of MATLAB functions (M-files) that
extend the MATLAB environment to solve particular classes of problems. Areas in which
toolboxes are available include signal processing, control systems, neural networks, fuzzy logic,
wavelets, simulation, and many others.
The MATLAB System
The MATLAB system consists of five main parts:
Development Environment. This is the set of tools and facilities that help you use MATLAB
functions and files. Many of these tools are graphical user interfaces. It includes the MATLAB
desktop and Command Window, a command history, and browsers for viewing help, the
workspace, files, and the search path.
The MATLAB Mathematical Function Library. This is a vast collection of computational
algorithms ranging from elementary functions like sum, sine, cosine, and complex arithmetic, to
more sophisticated functions like matrix inverse, matrix eigenvalues, Bessel functions, and fast
Fourier transforms.
The MATLAB Language.This is a high-level matrix/array language with control flow
statements, functions, data structures, input/output, and object-oriented programming features. It
allows both "programming in the small" to rapidly create quick and dirty throw-away programs,
and "programming in the large" to create complete large and complex application programs.

Handle Graphics®. This is the MATLAB graphics system. It includes high-level commands
for two-dimensional and three-dimensional data visualization, image processing, animation, and
presentation graphics. It also includes low-level commands that allow you to fully customize the
appearance of graphics as well as to build complete graphical user interfaces on your MATLAB
applications.
The MATLAB Application Program Interface (API). This is a library that allows you to
write C and FORTRAN programs that interact with MATLAB. It include facilities for calling
routines from MATLAB (dynamic linking), calling MATLAB as a computational engine, and
for reading and writing MAT-files.
DEVELOPMENT ENVIRONMENT
Introduction
This chapter provides a brief introduction to starting and quitting MATLAB, and
the tools and functions that help you to work with MATLAB variables and files. For more
information about the topics covered here, see the corresponding topics under Development
Environment in the MATLAB documentation, which is available online as well as in print.

Starting and Quitting MATLAB


Starting MATLAB
On a Microsoft Windows platform, to start MATLAB, double-click the MATLAB shortcut icon
on your Windows desktop.
On a UNIX platform, to start MATLAB, type matlab at the operating system
prompt.
After starting MATLAB, the MATLAB desktop opens - see MATLAB Desktop.
You can change the directory in which MATLAB starts, define startup options including running
a script upon startup, and reduce startup time in some situations.
Quitting MATLAB
To end your MATLAB session, select Exit MATLAB from the File menu in the
desktop, or type quit in the Command Window. To execute specified functions each time
MATLAB quits, such as saving the workspace, you can create and run a finish.m script.
MATLAB Desktop
When you start MATLAB, the MATLAB desktop appears, containing tools
(graphical user interfaces) for managing files, variables, and applications associated with
MATLAB.
The first time MATLAB starts, the desktop appears as shown in the following
illustration, although your Launch Pad may contain different entries.
You can change the way your desktop looks by opening, closing, moving, and
resizing the tools in it. You can also move tools outside of the desktop or return them back inside
the desktop (docking). All the desktop tools provide common features such as context menus and
keyboard shortcuts.
You can specify certain characteristics for the desktop tools by selecting
Preferences from the File menu. For example, you can specify the font characteristics for
Command Window text. For more information, click the Help button in the Preferences dialog
box.

Desktop Tools
This section provides an introduction to MATLAB's desktop tools. You can also
use MATLAB functions to perform most of the features found in the desktop tools. The tools
are:

 Current Directory Browser


 Workspace Browser
 Array Editor
 Editor/Debugger
 Command Window
 Command History
 Launch Pad
 Help Browser
Command Window
Use the Command Window to enter variables and run functions and M-files.
Command History
Lines you enter in the Command Window are logged in the Command History
window. In the Command History, you can view previously used functions, and copy and
execute selected lines. To save the input and output from a MATLAB session to a file, use the
diary function.
Running External Programs
You can run external programs from the MATLAB Command Window. The exclamation point
character! is a shell escape and indicates that the rest of the input line is a command to the
operating system. This is useful for invoking utilities or running other programs without quitting
MATLAB. On Linux, for example,!emacsmagik.m invokes an editor called emacs for a file
named magik.m. When you quit the external program, the operating system returns control to
MATLAB.
Launch Pad
MATLAB's Launch Pad provides easy access to tools, demos, and documentation.
Help Browser
Use the Help browser to search and view documentation for all your Math Works
products. The Help browser is a Web browser integrated into the MATLAB desktop that
displays HTML documents.
To open the Help browser, click the help button in the toolbar, or type
helpbrowser in the Command Window. The Help browser consists of two panes, the Help
Navigator, which you use to find information, and the display pane, where you view the
information.
Help Navigator
Use to Help Navigator to find information. It includes:
Product filter - Set the filter to show documentation only for the products you specify.
Contents tab -View the titles and tables of contents of documentation for your products.
Index tab - Find specific index entries (selected keywords) in the MathWorks
documentation for your products.
Search tab - Look for a specific phrase in the documentation. To get help for a specific
function, set the Search type to Function Name.
Favorites tab -View a list of documents you previously designated as favorites.

Display Pane
After finding documentation using the Help Navigator, view it in the display pane. While
viewing the documentation, you can:
Browse to other pages- Use the arrows at the tops and bottoms of the pages, or use the back and
forward buttons in the toolbar.
Bookmark pages - Click the Add to Favorites button in the toolbar.
Print pages - Click the print button in the toolbar.
Find a term in the page - Type a term in the Find in page field in the toolbar and click Go.
Other features available in the display pane are: copying information, evaluating a
selection, and viewing Web pages.
Current Directory Browser
MATLAB file operations use the current directory and the search path as
reference points. Any file you want to run must either be in the current directory or on the search
path.
Search Path
To determine how to execute functions you call, MATLAB uses a search path to
find M-files and other MATLAB-related files, which are organized in directories on your file
system. Any file you want to run in MATLAB must reside in the current directory or in a
directory that is on the search path. By default, the files supplied with MATLAB and
MathWorks toolboxes are included in the search path.
Workspace Browser
The MATLAB workspace consists of the set of variables (named arrays) built up during a
MATLAB session and stored in memory. You add variables to the workspace by using
functions, running M-files, and loading saved workspaces.
To view the workspace and information about each variable, use the Workspace browser, or use
the functions who and whos.
To delete variables from the workspace, select the variable and select Delete from
the Edit menu. Alternatively, use the clear function.

The workspace is not maintained after you end the MATLAB session. To save the
workspace to a file that can be read during a later MATLAB session, select Save Workspace As
from the File menu, or use the save function. This saves the workspace to a binary file called a
MAT-file, which has a .mat extension. There are options for saving to different formats. To read
in a MAT-file, select Import Data from the File menu, or use the load function.
Array Editor
Double-click on a variable in the Workspace browser to see it in the Array Editor.
Use the Array Editor to view and edit a visual representation of one- or two-dimensional numeric
arrays, strings, and cell arrays of strings that are in the workspace.
Editor/Debugger
Use the Editor/Debugger to create and debug M-files, which are programs you write to
runMATLAB functions. The Editor/Debugger provides a graphical user interface for basic
textediting, as well as for M-file debugging.
You can use any text editor to create M-files, such as Emacs, and can use
preferences (accessible from the desktop File menu) to specify that editor as the default. If you
use another editor, you can still use the MATLAB Editor/Debugger for debugging, or you can
use debugging functions, such as dbstop, which sets a breakpoint.
If you just need to view the contents of an M-file, you can display it in the
Command Window by using the type function.
MANIPULATING MATRICES
Entering Matrices
The best way for you to get started with MATLAB is to learn how to handle matrices. Start
MATLAB and follow along with each example.
You can enter matrices into MATLAB in several different ways:
 Enter an explicit list of elements.
 Load matrices from external data files.
 Generate matrices using built-in functions.
 Create matrices with your own functions in M-files.
Start by entering Dürer's matrix as a list of its elements. You have only to follow a few basic
conventions:
 Separate the elements of a row with blanks or commas.
 Use a semicolon, ; , to indicate the end of each row.
 Surround the entire list of elements with square brackets, [ ].

To enter Dürer's matrix, simply type in the Command Window


A = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1]
MATLAB displays the matrix you just entered.

A=
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1

This exactly matches the numbers in the engraving. Once you have entered the matrix, it is
automatically remembered in the MATLAB workspace. You can refer to it simply as A.
Expressions
Like most other programming languages, MATLAB provides mathematical
expressions, but unlike most programming languages, these expressions involve entire matrices.
The building blocks of expressions are:
 Variables
 Numbers
 Operators
 Functions
Variables
MATLAB does not require any type declarations or dimension statements. When
MATLAB encounters a new variable name, it automatically creates the variable and allocates the
appropriate amount of storage. If the variable already exists, MATLAB changes its contents and,
if necessary, allocates new storage. For example,
num_students = 25
Creates a 1-by-1 matrix named num_students and stores the value 25 in its single element.
Variable names consist of a letter, followed by any number of letters, digits, or
underscores. MATLAB uses only the first 31 characters of a variable name. MATLAB is case
sensitive; it distinguishes between uppercase and lowercase letters. A and a are not the same
variable. To view the matrix assigned to any variable, simply enter the variable name.
Numbers
MATLAB uses conventional decimal notation, with an optional decimal point and leading plus
or minus sign, for numbers. Scientific notation uses the letter e to specify a power-of-ten scale
factor. Imaginary numbers use either i or j as a suffix. Some examples of legal numbers are

3 -99 0.0001
9.6397238 1.60210e-20 6.02252e23
1i -3.14159j 3e5i

All numbers are stored internally using the long format specified by the IEEE
floating-point standard. Floating-point numbers have a finite precision of roughly 16 significant
decimal digits and a finite range of roughly 10-308 to 10+308.
Operators

Expressions use familiar arithmetic operators and precedence rules.

+ Addition
- Subtraction
* Multiplication
/ Division
\ Left division (described in "Matrices and Linear Algebra" in
Using MATLAB)
^ Power
' Complex conjugate transpose
() Specify evaluation order

Functions
MATLAB provides a large number of standard elementary mathematical
functions, including abs, sqrt, exp, and sin. Taking the square root or logarithm of a negative
number is not an error; the appropriate complex result is produced automatically. MATLAB also
provides many more advanced mathematical functions, including Bessel and gamma functions.
Most of these functions accept complex arguments. For a list of the elementary mathematical
functions, type
helpelfun
For a list of more advanced mathematical and matrix functions, type
helpspecfun
helpelmat
Some of the functions, like sqrt and sin, are built-in. They are part of the
MATLAB core so they are very efficient, but the computational details are not readily
accessible. Other functions, like gamma and sinh, are implemented in M-files. You can see the
code and even modify it if you want. Several special functions provide values of useful
constants.
Pi 3.14159265...
i Imaginary unit, √-1
I Same as i
Eps Floating-point relative precision, 2-52
Realmin Smallest floating-point number, 2-1022
Realmax Largest floating-point number, (2-ε)21023
Inf Infinity
NaN Not-a-number

GUI
A graphical user interface (GUI) is a user interface built with graphical objects,
such as buttons, text fields, sliders, and menus. In general, these objects already have meanings
to most computer users. For example, when you move a slider, a value changes; when you press
an OK button, your settings are applied and the dialog box is dismissed. Of course, to leverage
this built-in familiarity, you must be consistent in how you use the various GUI-building
components.
Applications that provide GUIs are generally easier to learn and use since the
person using the application does not need to know what commands are available or how they
work. The action that results from a particular user action can be made clear by the design of the
interface.
The sections that follow describe how to create GUIs with MATLAB. This
includes laying out the components, programming them to do specific things in response to user
actions, and saving and launching the GUI; in other words, the mechanics of creating GUIs. This
documentation does not attempt to cover the "art" of good user interface design, which is an
entire field unto itself. Topics covered in this section include:
Creating GUIs with GUIDE
MATLAB implements GUIs as figure windows containing various styles of uicontrol objects.
You must program each object to perform the intended action when activated by the user of the
GUI. In addition, you must be able to save and launch your GUI. All of these tasks are simplified
by GUIDE, MATLAB's graphical user interface development environment.
GUI Development Environment
The process of implementing a GUI involves two basic tasks:
 Laying out the GUI components
 Programming the GUI components
GUIDE primarily is a set of layout tools. However, GUIDE also generates an M-
file that contains code to handle the initialization and launching of the GUI. This M-file provides
a framework for the implementation of the callbacks - the functions that execute when users
activate components in the GUI.
The Implementation of a GUI
While it is possible to write an M-file that contains all the commands to lay out a
GUI, it is easier to use GUIDE to lay out the components interactively and to generate two files
that save and launch the GUI:
A FIG-file - contains a complete description of the GUI figure and all of its
children (uicontrols and axes), as well as the values of all object properties.
An M-file- contains the functions that launch and control the GUI and the
callbacks, which are defined as subfunctions. This M-file is referred to as the
application M-file in this documentation.
Note that the application M-file does not contain the code that lays out the
uicontrols; this information is saved in the FIG-file.
The following diagram illustrates the parts of a GUI implementation.
Features of the GUIDE-Generated Application M-File
GUIDE simplifies the creation of GUI applications by automatically generating
an M-file framework directly from your layout. You can then use this framework to code your
application M-file. This approach provides a number of advantages:
The M-file contains code to implement a number of useful features (see Configuring Application
Options for information on these features). The M-file adopts an effective approach to managing
object handles and executing callback routines (see Creating and Storing the Object Handle
Structure for more information). The M-files provides a way to manage global data (see
Managing GUI Data for more information).
The automatically inserted subfunction prototypes for callbacks ensure compatibility with future
releases. For more information, see Generating Callback Function Prototypes for information on
syntax and arguments.
You can elect to have GUIDE generate only the FIG-file and write the application M-file
yourself. Keep in mind that there are no uicontrol creation commands in the application M-file;
the layout information is contained in the FIG-file generated by the Layout Editor.
Beginning the Implementation Process
To begin implementing your GUI, proceed to the following sections:
Getting Started with GUIDE - the basics of using GUIDE.
Selecting GUIDE Application Options - set both FIG-file and M-file options.
Using the Layout Editor - begin laying out the GUI.
Understanding the Application M-File - discussion of programming techniques
used in the application M-file.
Application Examples - a collection of examples that illustrate techniques
which are useful for implementing GUIs.
Command-Line Accessibility
When MATLAB creates a graph, the figure and axes are included in the list of
children of their respective parents and their handles are available through commands such as
findobj, set, and get. If you issue another plotting command, the output is directed to the current
figure and axes.
GUIs are also created in figure windows. Generally, you do not want GUI figures
to be available as targets for graphics output, since issuing a plotting command could direct the
output to the GUI figure, resulting in the graph appearing in the middle of the GUI.
In contrast, if you create a GUI that contains an axes and you want commands
entered in the command window to display in this axes, you should enable command-line access.
User Interface Controls
The Layout Editor component palette contains the user interface controls that you
can use in your GUI. These components are MATLAB uicontrol objects and are programmable
via their Callback properties. This section provides information on these components.
 Push Buttons
 Sliders
 Toggle Buttons
 Frames
 Radio Buttons
 Listboxes
 Checkboxes
 Popup Menus
 Edit Text
 Axes
 Static Text
 Figures
Push Buttons
Push buttons generate an action when pressed (e.g., an OK button may close a
dialog box and apply settings). When you click down on a push button, it appears depressed;
when you release the mouse, the button's appearance returns to its nondepressed state; and its
callback executes on the button up event.
Properties to Set
String - set this property to the character string you want displayed on the push button.
Tag - GUIDE uses the Tag property to name the callback subfunction in the application M-
file. Set Tag to a descriptive name (e.g., close_button) before activating the GUI.
Programming the Callback
When the user clicks on the push button, its callback executes. Push buttons do not return a value
or maintain a state.
Toggle Buttons
Toggle buttons generate an action and indicate a binary state (e.g., on or off).
When you click on a toggle button, it appears depressed and remains depressed when you release
the mouse button, at which point the callback executes. A subsequent mouse click returns the
toggle button to the nondepressed state and again executes its callback.
Programming the Callback
The callback routine needs to query the toggle button to determine what state it is
in. MATLAB sets the Value property equal to the Max property when the toggle button is
depressed (Max is 1 by default) and equal to the Min property when the toggle button is not
depressed (Min is 0 by default).
From the GUIDE Application M-File

The following code illustrates how to program the callback in the GUIDE
application M-file.

functionvarargout = togglebutton1_Callback(h,eventdata,handles,varargin)
button_state = get(h,'Value');
ifbutton_state == get(h,'Max')
% toggle button is pressed
elseifbutton_state == get(h,'Min')
% toggle button is not pressed
end

Adding an Image to a Push Button or Toggle Button


Assign the CData property an m-by-n-by-3 array of RGB values that define a
truecolor image. For example, the array a defines 16-by-128 truecolor image using random
values between 0 and 1 (generated by rand).
a(:,:,1) = rand(16,128);
a(:,:,2) = rand(16,128);
a(:,:,3) = rand(16,128);
set(h,'CData',a)

Radio Buttons
Radio buttons are similar to checkboxes, but are intended to be mutually exclusive within a
group of related radio buttons (i.e., only one button is in a selected state at any given time). To
activate a radio button, click the mouse button on the object. The display indicates the state of
the button.
Implementing Mutually Exclusive Behavior
Radio buttons have two states - selected and not selected. You can query and set
the state of a radio button through its Value property:
Value = Max, button is selected.
Value = Min, button is not selected.
To make radio buttons mutually exclusive within a group, the callback for each
radio button must set the Value property to 0 on all other radio buttons in the group. MATLAB
sets the Value property to 1 on the radio button clicked by the user.
The following subfunction, when added to the application M-file, can be called by
each radio button callback. The argument is an array containing the handles of all other radio
buttons in the group that must be deselected.
functionmutual_exclude(off)
set(off,'Value',0)

Obtaining the Radio Button Handles.


The handles of the radio buttons are available from the handles structure, which
contains the handles of all components in the GUI. This structure is an input argument to all
radio button callbacks.
The following code shows the call to mutual_exclude being made from the first
radio button's callback in a group of four radio buttons.
functionvarargout = radiobutton1_Callback(h,eventdata,handles,varargin)
off = [handles.radiobutton2,handles.radiobutton3,handles.radiobutton4];
mutual_exclude(off)
% Continue with callback
.
.
.

After setting the radio buttons to the appropriate state, the callback can continue
with its implementation-specific tasks.

Checkboxes
Check boxes generate an action when clicked and indicate their state as checked
or not checked. Check boxes are useful when providing the user with a number of independent
choices that set a mode (e.g., display a toolbar or generate callback function prototypes).
The Value property indicates the state of the check box by taking on the value of
the Max or Min property (1 and 0 respectively by default):
Value = Max, box is checked.
Value = Min, box is not checked.
You can determine the current state of a check box from within its callback by
querying the state of its Value property, as illustrated in the following example:
function checkbox1_Callback(h,eventdata,handles,varargin)
if (get(h,'Value') == get(h,'Max'))
% then checkbox is checked-take approriate action
else
% checkbox is not checked-take approriate action
end

Edit Text
Edit text controls are fields that enable users to enter or modify text strings. Use
edit text when you want text as input. The String property contains the text entered by the user.
To obtain the string typed by the user, get the String property in the callback.
function edittext1_Callback(h,eventdata, handles,varargin)
user_string = get(h,'string');
% proceed with callback...
Obtaining Numeric Data from an Edit Test Component
MATLAB returns the value of the edit text String property as a character string. If
you want users to enter numeric values, you must convert the characters to numbers. You can do
this using the str2double command, which converts strings to doubles. If the user enters non-
numeric characters, str2double returns NaN.
You can use the following code in the edit text callback. It gets the value of the
String property and converts it to a double. It then checks if the converted value is NaN,
indicating the user entered a non-numeric character (isnan) and displays an error dialog
(errordlg).
function edittext1_Callback(h,eventdata,handles,varargin)
user_entry = str2double(get(h,'string'));
ifisnan(user_entry)
errordlg('You must enter a numeric value','BadInput','modal')
end
% proceed with callback...
Triggering Callback Execution
On UNIX systems, clicking on the menubar of the figure window causes the edit text callback to
execute. However, on Microsoft Windows systems, if an editable text box has focus, clicking on
the menubar does not cause the editable text callback routine to execute. This behavior is
consistent with the respective platform conventions. Clicking on other components in the GUI
execute the callback.

Static Text
Static text controls displays lines of text. Static text is typically used to label other
controls, provide directions to the user, or indicate values associated with a slider. Users cannot
change static text interactively and there is no way to invoke the callback routine associated with
it.

Frames
Frames are boxes that enclose regions of a figure window. Frames can make a
user interface easier to understand by visually grouping related controls. Frames have no
callback routines associated with them and only uicontrols can appear within frames (axes
cannot).

Placing Components on Top of Frames

Frames are opaque. If you add a frame after adding components that you want to
be positioned within the frame, you need to bring forward those components. Use the Bring to
Front and Send to Back operations in the Layout menu for this purpose.
List Boxes
List boxes display a list of items and enable users to select one or more items.

The String property contains the list of strings displayed in the list box. The first
item in the list has an index of 1.
The Value property contains the index into the list of strings that correspond to
the selected item. If the user selects multiple items, then Value is a vector of indices.

By default, the first item in the list is highlighted when the list box is first
displayed. If you do not want any item highlighted, then set the Value property to empty, [].

The ListboxTop property defines which string in the list displays as the top most
item when the list box is not large enough to display all list entries. ListboxTop is an index into
the array of strings defined by the String property and must have a value between 1 and the
number of strings. Noninteger values are fixed to the next lowest integer.

Single or Multiple Selection

The values of the Min and Max properties determine whether users can make
single or multiple selections:

If Max - Min > 1, then list boxes allow multiple item selection.
If Max - Min <= 1, then list boxes do not allow multiple item selection.

Selection Type
Listboxes differentiate between single and double clicks on an item and set the figure
SelectionType property to normal or open accordingly. See Triggering Callback Execution for
information on how to program multiple selection.

Triggering Callback Execution


MATLAB evaluates the list box's callback after the mouse button is released or a
keypress event (including arrow keys) that changes the Value property (i.e., any time the user
clicks on an item, but not when clicking on the list box scrollbar). This means the callback is
executed after the first click of a double-click on a single item or when the user is making
multiple selections.

In these situations, you need to add another component, such as a Done button
(push button) and program its callback routine to query the list box Value property (and possibly
the figure SelectionType property) instead of creating a callback for the list box. If you are using
the automatically generated application M-file option, you need to either:

Set the list box Callback property to the empty string ('') and remove the callback
subfunction from the application M-file. Leave the callback subfunction stub in the application
M-file so that no code executes when users click on list box items.

The first choice is best if you are sure you will not use the list box callback and
you want to minimize the size and efficiency of the application M-file. However, if you think
you may want to define a callback for the list box at some time, it is simpler to leave the callback
stub in the M-file.
Popup Menus
Popup menus open to display a list of choices when users press the arrow.

The String property contains the list of string displayed in the popup menu. The
Value property contains the index into the list of strings that correspond to the selected item.

When not open, a popup menu displays the current choice, which is determined
by the index contained in the Value property. The first item in the list has an index of 1.

Popup menus are useful when you want to provide users with a number of
mutually exclusive choices, but do not want to take up the amount of space that a series of radio
buttons requires.
Programming the Popup Menu
You can program the popup menu callback to work by checking only the index of the item
selected (contained in the Value property) or you can obtain the actual string contained in the
selected item.

This callback checks the index of the selected item and uses a switch statement to
take action based on the value. If the contents of the popup menu is fixed, then you can use this
approach.

functionvarargout = popupmenu1_Callback(h,eventdata,handles,varargin)
val = get(h,'Value');
switchval
case 1
% The user selected the first item
case 2
% The user selected the second item
% etc.

This callback obtains the actual string selected in the popup menu. It uses the
value to index into the list of strings. This approach may be useful if your program dynamically
loads the contents of the popup menu based on user action and you need to obtain the selected
string. Note that it is necessary to convert the value returned by the String property from a cell
array to a string.

functionvarargout = popupmenu1_Callback(h,eventdata,handles,varargin)
val = get(h,'Value');
string_list = get(h,'String');
selected_string = string_list{val}; % convert from cell array to string
% etc.

Enabling or Disabling Controls


You can control whether a control responds to mouse button clicks by setting the
Enable property. Controls have three states:

on - The control is operational


off - The control is disabled and its label (set by the string property) is
grayed out.
inactive - The control is disabled, but its label is not grayed out.

When a control is disabled, clicking on it with the left mouse button does not
execute its callback routine. However, the left-click causes two other callback routines to
execute:

First the figure WindowButtonDownFcn callback executes. Then the control's


ButtonDownFcn callback executes.

A right mouse button click on a disabled control posts a context menu, if one is
defined for that control. See the Enable property description for more details.
Axes
Axes enable your GUI to display graphics (e.g., graphs and images). Like all graphics objects,
axes have properties that you can set to control many aspects of its behavior and appearance. See
Axes Properties for general information on axes objects.

Axes Callbacks
Axes are not uicontrol objects, but can be programmed to execute a callback when users click a
mouse button in the axes. Use the axes ButtonDownFcn property to define the callback.

Plotting to Axes in GUIs


GUIs that contain axes should ensure the Command-line accessibility option in
the Application Options dialog is set to Callback (the default). This enables you to issue plotting
commands from callbacks without explicitly specifying the target axes.
GUIs with Multiple Axes

If a GUI has multiple axes, you should explicitly specify which axes you want to target when
you issue plotting commands. You can do this using the axes command and the handles
structure. For example,

axes(handles.axes1)

makes the axes whose Tag property is axes1 the current axes, and therefore the target for plotting
commands. You can switch the current axes whenever you want to target a different axes. See
GUI with Multiple Axes for and example that uses two axes.

Figure
Figures are the windows that contain the GUI you design with the Layout Editor.
See the description of figure properties for information on what figure characteristics you can
control.
CHAPTER
IMPLEMENTATION

1. Introduction
A graphical user interface (GUI) is a graphical display in one or more windows containing
components that enable a user to perform interactive tasks [1]. The GUI user does not have to
create a script or type commands at the command line to accomplish the tasks. Unlike coding
programs to accomplish tasks, the GUI user need not understand the details of how the tasks are
performed. GUI components include menus, toolbars, push buttons, radio buttons, list boxes, and
sliders, etc. GUI is created using MATLAB tools, it can also perform any type of computation,
read and write data files, communicate with other GUIs, and display data as tables or as plots [1,
2]
2. Classification of Communication System
Communication is the basic process of exchanging information. The basic components of
electronics and communication system are: 1. Transmitter: It is a collection of electronic circuits
designed to convert the information into a signal suitable for transmission over a giver
communication medium [8]. 2. Channel: It is the medium by which the electronic signal is
transmitter from one place [8].
3. Receiver: It is a collection of electronic circuits designed to convert the signal back to the
original information [8].
3. Modulation & Demodulation Processes
Modulation: The process of changing some characteristic (e.g. amplitude, frequency or phase) of
a carrier wave in accordance with the intensity of the signal is known as modulation. The
resultant wave is called as modulated wave. Demodulation: The process of recovering the
original signal from the modulated wave is known as demodulation or detection.
4. Need of Modulation
Baseband signals are incompatible for direct/long transmission. For such signals to make them
travel longer distance, its strength has to be increased by applying modulation process with a
high frequency carrier wave, which doesn’t affect the parameters of the modulating signal [7]
and results into a modulated wave.
5. Advantages of Modulation
The advantages of modulation are as follows: Reduction of antenna size No signal mixing
Increased communication range Possibility of bandwidth adjustment 6. Types of Modulation
There are various types of modulation and demodulation processes. Depending upon the
techniques used, they are classified as [7]:

7. System Designing
A graphical user interface provides user a familiar environment to work [4]. This environment
contains pushbuttons, toggle buttons, lists, menus, text boxes, and so forth, all of which are
already familiar to the user, so that the user can concentrate on using the application rather than
on the mechanics involved in doing things [4]. MATLAB includes high-level commands for
two-dimensional and three-dimensional data visualization, image processing, and presentation
graphics. However, designing GUI is a difficult task for the programmer because a GUI-based
program must be prepared for mouse clicks (or possibly keyboard input) for any GUI element at
any time [4]. Figure 2 shows various buttons of GUI.
The main elements required to create MATLAB Graphical User Interface are as follows and is
shown in Figure 3.
(a) Components- Each item on a MATLAB GUI (pushbuttons, labels, edit boxes, etc.) is a
graphical component. The types of components include graphical controls (pushbuttons, edit
boxes, lists, sliders, etc.), static elements(frames and text strings), menus, and axes. Graphical
controls and static elements are created by the function control, and menus are created by the
functions menu and context menu. Axes, which are used to display graphical data, are created by
the function axes [4].
(b) Figures-The components of a GUI must be arranged within a figure, which is a window on
the computer screen. Empty figures can be created with the function figure and can be used to
hold any combination of components [4]. Use graphical elements that perform a dual function:
display data and interaction. For example, a plotted line can both display data and can alter data
when a user click on the line drag it on a new position. Use mouse downs, drags, and mouse ups
anywhere within the figure to perform an action.
(c) Callbacks -Finally, there must be some way to perform an action if a user clicks a mouse on a
button or types information on a keyboard. A mouse click or a key press is an event, and the
MATLAB program must respond to each event if the program is to perform its function. For
example, if a user clicks on a button, that event must cause the MATLAB code that implements
the function of the button to be executed. The code executed in response to an event is known as
a call back. There must be a callback to implement the function of each graphical component on
the GUI [4].

7.1.Tools used in Designing the GUI

7.2.Developing GUI for Modulation and Demodulation Step 1: Developing Graphical User
Interface for Modulation and Demodulation using MATLAB. Begin to create MATLAB GUI by
creating their figure file name fig-file. By typing ‘GUIDE’ at the command window, A GUIDE
Quick Start window will prompt out [5] as shown in Figure 4 Figure 5 and Figure 6.
Step 2: Add function for GUI by dragging component from component palette. There is Push
Button, Slider, Radio Button, Check Box, Edit Text, Static Text, Pop-up Menu, List Box, Toggle
Button, Axes, Panel, Button Group, and Active X Control [5, 6]. For example, if you drag push
buttons and axes into the layout area and arrange it and the same arrangements of push buttons
and axis is shown in Figure 7.
Step 3: Open the Property Inspector at View > Property Inspector to change the name of
pushbutton, Panel and other function name[5] as shown in Figure 8.
Step 4: Run the GUI by click the run Button To run a GUI, select Run from the Tools
menu, or click the run button on the toolbar. This displays the functioning of GUI outside
the Layout Editor. GUIDE stores a GUI in two files, which are generated the first time save
or run the GUI: FIG-file, with extension .fig, which contains a complete description of the
GUI layout and the components of the GUI: push buttons, menus, axes, and so on [5,
6].Figure 9 represents the GUI after the run command is executed.

Step 5: M-file with extension .m, that contains the code controls the GUI, including the callbacks
for its components. These two files correspond to the tasks of laying out and programming the
GUI. When lay out of the GUI in the Layout Editor the works is stored in the FIG-file. While
programming GUI the work is stored in the Mfile [5, 6]. Step 6: After preparing the layout of the
GUI, the programming of GUI can be done in M-file using the M-file editor. GUIDE
automatically generates this file from your layout as soon as you save or run the GUI. The GUI
Mfile initializes the GUI that contains code to perform tasks before the GUI appears on the
screen, such as creating data or graphics that contains callback functions that are executed each
time a user clicks a GUI component. Initially, each callback contains just a function definition
line. Use the M-file editor to add code that makes the component. To open the M-file, click the
M-file Editor icon on the Layout Editor Toolbar. You can view the callback for any of the GUI
components by clicking the function icon on the toolbar. This displays a list of all the callbacks,
as shown in Figure 10
CHAPTER
ADVANTAGES
As the signals are digitized, there are many advantages of digital communication over analog
communication, such as −
 The effect of distortion, noise, and interference is much less in digital signals as they are
less affected.
 Digital circuits are more reliable.
 Digital circuits are easy to design and cheaper than analog circuits.
 The hardware implementation in digital circuits, is more flexible than analog.
 The occurrence of cross-talk is very rare in digital communication.
 The signal is un-altered as the pulse needs a high disturbance to alter its properties, which
is very difficult.
 Signal processing functions such as encryption and compression are employed in digital
circuits to maintain the secrecy of the information.
 The probability of error occurrence is reduced by employing error detecting and error
correcting codes.
 Spread spectrum technique is used to avoid signal jamming.
 Combining digital signals using Time Division Multiplexing (TDM) is easier than
combining analog signals using Frequency Division Multiplexing (FDM).
 The configuring process of digital signals is easier than analog signals.
 Digital signals can be saved and retrieved more conveniently than analog signals.
 Many of the digital circuits have almost common encoding techniques and hence similar
devices can be used for a number of purposes.
 The capacity of the channel is effectively utilized by digital signals.
 The digital communication systems are simpler and cheaper compared to analog
communication systems because of the advances made in the IC technologies.
 In digital communication, the speech, video and other data may be merged and
transmitted over a common channel using multiplexing.
 Using data encryption, only permitted receivers may be allowed to detect the transmitted
data. This property is of its most importance in military applications.
 Since the transmission is digital and the channel encoding is used, therefore the noise
does not accumulate from repeater to repeater in long distance communications.
 Since the transmitted signal is digital in nature, therefore, a large amount of noise
interference may be tolerated.
 Since in digital communication, channel coding is used, therefore, the errors may be
detected and corrected in the receivers.
 Digital communication is adaptive to other advanced branches of data processing such as
digital signal processing, image processing and data compression, etc.
 Digital communication systems are cheaper to implement.It is possible to
manufacture very high speed embedded circuits due to advancements in VLSI
technology in cost effective manner . Such circuits are used in digital
communications.
 Digital communication allows regenaration the digital signal in long distance
transmission which reduces noise effect.
 3). Good processing techniques are available for digital signals such as source
coding (data compression), channel coding ( error detection and correction),
equalization etc.
 Easy to mix signals and data using digital techniques.

 5). Privacy is preserved by using data encryption. Using data encryption. only
permitted receivers can be allowed to detect the transmitted data. This is very
useful in military applications.
 6).High speed computers and powerful software design tools are available.
They make the development of digital communication systems flexible.
 7). Internet is spread almost in every cities and towns. The compat ibility of
digital communication systems with Internet has opened new area of
applications
1. Transmission quality is almost independent of the distance between The error rate is virtually
unaffected by distance due to the regeneration, or cleaning up, of the signal at the regenerators.
2. A mixture of traffic, ranging from telephony and telegraphy to data and video information can be easily
carried.
3. The capacity of certain existing transmission systems can be increased. For instance, the capacity of a
single channel over a cable pair can be increased by employing digital multiplexing equipment,
whereby several signals are combined into a higher rate signal without any significant impairment.
Similarly, the capacity of a satellite communication system can be increased by going to TDM access.
4. Digital cable systems are more economical for distances of 15-40 km, particularly if cable capacity is
nearly exhausted. It is more economical to convert to digital on the old cable rather than by laying new
cables or provide new ductways.
5. Digital Communication System lends itself to such novel facilities as cryptography, storage and other
forms of digital processing.
6. Digital Communication System is more suitable for the newer types of transmission media, such as
light beams in optical fibers and circular or helical wave guides operating around 30 to 100 GHz.
7. Digital signal characteristics are convenient for electronic switching, in which groups of digits are
selected to be switched in turn onto various This is called packed switching.

Disadvantages
 Due to analog to digital conversion, the data rate becomes high. therefore more
transmission bandwidth is required for digital communication.
 Digital communication needs synchronization in case of synchronous modulation.
 1). Generally, more bandwidth is required than that for a nalog systems.
 2). Synchronization is required.

 3). High power consumption (Due to various stages of conversion).


 4). Complex circuit, more sofisticated device making is also drawbacks of
digital system.
 5). Introduce sampling error
 6). As square wave is more affected by noise, That’s why while
communicating through channel we send sin waves but while operating on
device we use squire pulses.
One of the major disadvantages of a digital system is its large band width requirement. An audio
channel, which may normally require an analog band width of 4 kHz, will require 64 kHz when
transmitted by a PCM (digital) system. This can be reduced by signal processing and the
employment of special modulation techniques, but at the expense of increased costs and
complexity.
Time division digital transmission is not compatible with the frequency division analog
transmission in current use. Both cannot be carried simultaneously, as can be done, for instance,
with mono and stereo FM.
CHAPTER
SIMULATION RESULTS
CHAPTER
CONCLUSION

In this project the MATLAB based GUI is designed and described for various waveforms based
on signal processing tool. The authors have tried their level best to make the Modulation and
Demodulation tool as user friendly as possible. The purpose of the modulation and demodulation
tool is to bring the various signals functions available in MATLAB tool box under one common
platform and to make it easier for the understanding of any user.
REFERENCES
1) Refaat Yousef Al Ashi, Ahmed Al Ameri, Prof. Abdulla Ismail Abdulla, Introduction To
Graphical User Interface (GUI) Matlab 6.5, College Of Engineering, Electrical
Engineering Department, IEEE UAEU Student Branch, UAE University.
2) Mistry Kaushik P, Prajapati Simpal K, Patel Jenish C, Machhi Devis M, A MATLAB
Based GUI for Various Signals Testing and Analysis of Filter (IJSRD - International
Journal for Scientific Research & Development| Vol. 3, Issue 02, 2015 | ISSN (online):
2321-0613).
3) https://www.quora.com/What-is-modulation-anddemodulation-in-a-modem
4) Stephen J. Chapman, MATLAB Programming for Engineers, 5th Edition, 2008.
5) Muhammad Lokman Al-Hakim Bin Abu Bakar, Graphical User Interface for Signal
Generator, University Malaysia Pahang, Malaysia.
6) Online: http://www.mathworks.in/videos/creatinga-gui-with-guide-68979.html
7) https://www.tutorialspoint.com/analog_communication/analog_communication_modulati
on.html
8) http://physics.tutorvista.com/waves/modulation.html

You might also like