Научная статья на тему 'Introduction to signal processing: sampled signals'

Introduction to signal processing: sampled signals Текст научной статьи по специальности «Физика»

CC BY
283
67
i Надоели баннеры? Вы всегда можете отключить рекламу.
Область наук
Ключевые слова
DATA RATE / DIRAC COMB / DISCRETE FOURIER TRANSFORM (DFT) / DISCRETE-TIME SIGNAL / FAST FOURIER TRANSFORM (FFT) / LOW PASS FILTER / MATLAB / NYQUIST-SHANNON-KOTELNIKOV THEOREM / RC-CIRCUIT / SAMPLING / SAMPLING THEOREM / SINC-FILTER / TELEPHONE COMMUNICATION

Аннотация научной статьи по физике, автор научной работы — Tikhonov Eugene, Sneps-Sneppe Manfred

The article introduces the theoretical foundations of the modern method of storing, transmitting and processing signals: digital processing. It’s a way to use relatively small number of values instead of continuous real signal. For example, when transmitting information in telephony, speech is concentrated in the bandwidth up to 4 kHz. But we need doubled frequency 8 kHz sampling in digital form. This is a fundamental requirement. The reason is that the sampled signal is not just a set of quantities, but a set of short scaled pulses of large value. Resulting spectrum has multiple copies of original one infinitely duplicated on sampling frequency steps. If these copies do not overlap significant (due to the limited original useful spectrum) we could restore initial signal with filtering just one of them. That’s why doubled sampling frequency is needed. If the number of samples used is finite (as in the real cases), then we can use only an equal number of samples of the spectrum (or even a half of them). It’s enough for restoring. As in the rest parts of the series, all theoretical ideas are illustrated by mathematical rationales and Matlab programs that demonstrate the work “in life”.

i Надоели баннеры? Вы всегда можете отключить рекламу.
iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.
i Надоели баннеры? Вы всегда можете отключить рекламу.

Текст научной работы на тему «Introduction to signal processing: sampled signals»

Introduction to signal processing: sampled

signals

E. Tikhonov and M. Sneps-Sneppe

Abstract — The article introduces the theoretical foundations of the modern method of storing, transmitting and processing signals: digital processing. It's a way to use relatively small number of values instead of continuous real signal.

For example, when transmitting information in telephony, speech is concentrated in the bandwidth up to 4 kHz. But we need doubled frequency 8 kHz sampling in digital form. This is a fundamental requirement.

The reason is that the sampled signal is not just a set of quantities, but a set of short scaled pulses of large value. Resulting spectrum has multiple copies of original one infinitely duplicated on sampling frequency steps. If these copies do not overlap significant (due to the limited original useful spectrum) we could restore initial signal with filtering just one of them. That's why doubled sampling frequency is needed.

If the number of samples used is finite (as in the real cases), then we can use only an equal number of samples of the spectrum (or even a half of them). It's enough for restoring.

As in the rest parts of the series, all theoretical ideas are illustrated by mathematical rationales and Matlab programs that demonstrate the work "in life".

Keywords — Data rate, Dirac comb, Discrete Fourier Transform (DFT), discrete-time signal, Fast Fourier Transform (FFT), low pass filter, MatLab, Nyquist-Shannon-Kotelnikov theorem, RC-circuit, Sampling, sampling theorem, sinc-filter, telephone communication.

I. INTRODUCTION

The article continues the introduction to a signal processing tasks for radio astronomy measurements and satellite data collection that could be used in the "Ventspils International Radio Astronomy Center" of the Ventspils University of Applied Sciences.

In previous papers complex signal representation [1] and spectral analysis principles [2] were discussed. Current article is dedicated to basics of discrete approximations of a signal for digital processing.

The rest of the paper is the following. In Section 2 example of digital voice transmit is given (comparing with analogous). Section 3 suggests mathematical description of sampled signal and corresponding spectrum changes. In Section 4 restoring original continuous signal from these samples and in Section 5 restoring the samples from spectrum samples are discussed.

All the Matlab codes (used as the examples and produced

Manuscript received May 31, 2019.

Eugene Tikhonov is with Ventspils University of Applied Sciences,

101a Inzenieru Street, LV-3601, Ventspils, Latvia (e-mail: abava@abava.net).

Manfred Sneps-Sneppe is with Ventspils University of Applied

Sciences, 101a Inzenieru Street, LV-3601, Ventspils, Latvia (e-mail: amanfredss@venta.lv).

illustration figures to all parts) are collected in the Appendix.

II. Digital voice transmission

The basic concept of telephone communication is the so-called channel of tone frequency. Why? Formants of voice that determining speech intelligibility are located mainly in the frequency range from 300 to 3 400 Hz. So for the analog voice telephony, the band frequency 4 kHz is usually allocated for transmission of each channel [6].

Currently, signal processing is usually done digitally - on digital computers (or specialized digital processors). They do spectral analysis, filtering, storage and transmission in digital form [3]. That means only a certain set of signal values are selected from the real signal - samples.

If we use the digital transmission, then according to the Kotelnikov theorem one should take the sampling rate of 8 000 counts per second (8 kHz) - twice as much. This is a deep and direct consequence of the discrete nature of the signal obtained from the continuous.

The theorem was proposed and proved by Vladimir Kotelnikov in 1933 in his work "On the capacity of ether and wire in telecommunications", in which the theorem was formulated as follows:

"Any function f(t) consisting of frequencies from 0 to fc can be continuously transmitted with any accuracy using numbers following each other in — [4].

2 JC

The theorem was discovered by several authors independently. It is thus also known by the names Nyquist-Shannon-Kotelnikov, and cardinal theorem of interpolation, also sampling theorem, and Whittaker-Shannon interpolation formula [5].

Pulse-code modulation of a signal

Time, 1

Fig 1. Pulse-code modulation (PCM) is a method used to digitally represent sampled analog signals. Sampling and quantization of a signal (red) for 4-bit linear pulse-code modulation (LPCM).

In previous articles of the series [1] and [2], we used MatLab scripts that simulates continuous signals by a large number of points. In fact, we intuitively believe that if we take a lot of samples, we will get the same (or almost the same) result as for a real continuous signal. Is this true, and how many samples should we get?

III. Discrete signals

In digital signal processing (for example for digital computer processing with quantized time ticks) we have a deal with not continuous in time analog signal s(t), but with discrete signal (or discrete-time signal) - set or sequence of signal value samples set in different times {s„}[6]. In most useful cases each value set at equal time intervals T (sampling time):

sn = s(T x n)

Also data values of such signal could be not continuous but also discrete (they can only take on one of a finite number of values) - this type of signal is called discrete-value signal. Discrete-time discrete-value signal is called digital signal, and it's possible values called symbols.

For the important case, where signal has only 2 possible values 0 ("false") and 1 ("true") it is called bitstream. Transmitted number in this case represented as a sequence of sequential bits xt = [0,1]:

x = ^ xk x2k k

If signal takes 2N possible values also say that it contains N bits for each symbol (because each symbol could be represented as N bits). Bitstream obviously is a sequence of 1-bit symbols "0" and "1".

Further we will not pay special attention to the quantification of values, only the discretization of the signal in time.

Parameter of a discrete signal that shows how many values in second contained in a digital signal called signal data rate. signal bitrate is a number of bits per second in digital signal (for the case of bitstream is equals to data rate obviously). For example, if {s„} has K symbols per second and each symbol contain M bits, then: data rate is K, bitrate is K x M.

for the voice telephony example discussed earlier, the numerical value of each sample is represented as a 7 or 8-bit binary code (that means each sample value if from 0 to 127 or to 255). So in the world of telecommunications there are two transmission systems - at a speed of 56 (8 kHz * 7 bits) or 64 (8 kHz* 8 bits) kbit/s.

This is not about the amount of useful information contained in the signal in general. An overview of the various encoding and compression methods is not included in this article devoted only to the transmission of the physical values of a given signal.

A. What is a discrete signal

The discrete signal fundamentally differs from continuous. It is shown in mathematics that rational numbers (that is, those that can be numbered in principle, even if there are an infinite number) are fundamentally smaller than the real numbers (which belong to the values of continuous signals) that form the "continuum" (continuum) [7]. That is,

even the smallest continuous variable signal will be "more powerful" than any number of fixed samples, no matter how many there are.

Due to the fact that the samples are just a set of points (or numbers), we cannot simply use them in the real world instead of continuous signals because of their finite value and zero duration.

Therefore, a discrete signal means a special function that depends on these number samples, used as the height of the corresponding delta functions, following each other after a sampling time interval T:

^sampled

(t) = ^ snS(t - nT)

a) Signal continuous s(t)

1 2 Time, t

c) Sampling comb d(t)

1

1

! 05 *

0

-0.5 3 0

b) Signal values s(nT)

12 Time, t

d) Sampled signal s (t)

sampled

1

0 5 <[> 0

QQaQQQQQQ

_. -0.5 30

Fig. 2. Example of the sampled signal: the initial continuous signal (a), sampled values of the continuous signal (b), Dirac comb of delta functions - marked with vertical lines with a height equal to the area (c), sampled signal that is Dirac comb scaled with the samples (d). See Matlab code in Appendix B.

This is an idealized representation, because the delta functions are mathematical abstraction.

Some approximations can also be sequences of pulses (for example, short rectangular ones with a large voltage value), and the shorter their duration, the less distortions due to their shape will be introduced. This clearly illustrates the definition of the delta function as the limit of suitable pulses, which we used earlier [2].

Instead of infinite summation limits, finite ones can be used (if the original signal is time limited), for example, from 0 to N. In this case, the signal can be considered original, defined at infinity, multiplied by a function that takes values in the appropriate limits 1, and 0 is outside these limits.

B. How the signal changes if only samples are used from it

At first sight, we lose an infinite amount of information, because there were continuous intervals with an uncountable number of points, and only individual values remain.

However, under certain conditions, it is possible to restore the original continuous signal absolutely precisely from this limited number of points. In practice, even if these conditions are not strictly fulfilled, a fairly close result can be obtained.

3

0

2

3

Time, t

Time, t

To demonstrate that we could use spectral analysis using Fourier Transform [2]. The spectrum is one-to-one identifies the signal. So if the spectra of the two signals are the same, then the signals are the same.

Therefore, we consider what happens to the signal spectrum, if only samples have been selected from it.

We can write the function of a discrete signal as a product of the original continuous signal by a special function:

-'sampled

(t) = s(t) x X <5(t- nT)

d(t)

s(t) = f(t)g(t) ~ S(o) = -2= J s(t)e-J'

—œ

œ

= -2= J f(t)g(t)e—j°Jtdt

iMtdt

CO

= -SJm

CO

— f G(u)e+iutdu -2л J

CO

=± f 2л J

—œ

œ

= 1 f 2л J

G(u)

uu

iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.

Jm<

—'Mtdt

-j(a>—u)tdt

du

G(u)F(w - u)du = — x(G* F)(w) 2л

Therefore, if we select samples from the signal (using the Dirac Comb), the total spectrum will be a convolution of the original spectrum with the Comb spectrum. What is the Dirac Comb spectrum:

вЫ= -LJm

—Mtdt

œ

= J X w -T xn)е—Ы'dt

—ОЭ n=—CO f f

=— X f

-2л ^ J

S(t -T x n)e—1 dt

=— —œ

=— X

V2л ^

y—j со nT

See Appendix A . oo

V2n v^ 2n

= — L S(a>-Tn)

n=-&i

A detailed calculation of some steps (marked above in the formula) is given in Appendix A.

So, the Dirac comb in time (with the time step T and the scale 1) is a Dirac comb in frequencies space (with the

frequency step ^r and the scale

1.5

a) Time sampling d(t)

1G 99999999999999999999 0.6 0

This d(t) function used for sampling is called the Dirac comb:

d(t)= ^ S(t -T xn),r EZ

n=-&i

The spectrum of the product of two signals (Fourier transform) is the already known operation of convolution of the original signals (with some scaling):

I 2

-2-10 1 2 Time t, sec. b) Frequency sampling D(uj)

C)ÏS

-30 -20 -10 0 10 20 30

Frequency cj, rad/sec.

Fig. 3. Dirac comb in time space временном (a) and frequency space (b). See Matlab code in Appendix C.

Filtering property of the delta function means that convolution with it shifts the function to a given point. Therefore, the spectrum of the sampled signal is original continuous signal spectrum scaled by and copied with a

2n

step of — equals to the sampling frequency : 1

SsampIed О) = 2^X(S * D)(C°)

=2n J s(u)°(ш

1

2л -2л

CO ОЭ

J s(u) X

и) du

( -

2

--n) du

T )

=ял X J

=—œ —œ

2

—T n) du

œ

= T-k Xs("-Tn)

■n] du

| Signal s(t) = rectangularPulse(0, 1, t), and sampling sn

ä(t)

Samples sn

-- Sampled s,ampia(t)

Restored sreatored(t)

0.S

0 12 3 4

Time, t (sec)

b) Spectrum of a signal 5(uj)—(cos(w)*li + sin(w))/w - li/w

Frequency w, rad/s

Re S(u>)

c) Spectrum Ssampled(w) of sampled signal sn

Frequency ixi, rad/s

Re S(u)

S

-40 -30 -20 -10 0 10 20 frequency, lj (rad/s)

Xi <

-30 -20 -10 0 10 20 Frequency u, rad/s

-40 -30 -20 -10 0 10 20 Frequency u, rad/s

30 40

30 40

-1 -'-'-'-'-'-'-'-'-'-'

-50 -40 -30 -20 -10 0 10 20 30 40 50 frequency w, rad/s

frequency ui, rad/s

K -

-50 -40 -30 -20 -10 0 10 20 30 40 50 frequency ui, rad/s

Fig. 4. single rectangular pulse signal sampling: continuous signal, samples and sampled signal (a), spectrum of the original signal (b), spectrum of the sampled signal (c). See Matlab code in Appendix D.

IV. Kotelnikov Theorem: continuous signal

RECOVERY FROM THE SAMPLES

As we see the spectrum of sampled (discretized) signal is different from the original continuous.

In the general case, the copies of a spectrum are superimposed on each other and distort so that it is impossible to obtain the original back (to restore the continuous signal).

However, for example, if the step between copies of the spectra (equal to the sampling frequency) is large enough compared to the width of the spectrum itself, they can be divided (by filtering all but one copy). Since the copies are

2n

located at a distance of the sampling frequency — from each other, the width of the spectrum of the continuous signal should be 2 times smaller than this step so that they do not overlap. This is the essence of Kotelnikov's theorem.

A. Restoring with the ideal low pass filter

To do this, we can apply an ideal low-pass filter (leaving only frequencies from 0 to H) or a band-pass filter (extracting the shifted spectrum from other copies), for example:

Srestored

(co)

S sampled **lowpass

(w) x T-2Ü

Where H>

iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.

lowpass

is the transfer ratio (the value at the

output of the filter divided by the value at the input): H {,* = l1, M< n

nlowpass W lo, |ftj| >H

Impulse response (inversed Fourier transform) for it:

m= ¿¡¡¡J'

-n

eiMtd(ß =

1 gjnt — e-jnt

42n jt

2D. sin Dt

: x ■

=

CO

-mJa(T)

e-°'TdT

e'wtdM

oo

J F(œ)eiM(t-T)dœ

dr

=h\ 9{j)f{t - J)dT=h{a* fm

—o

Thus, the signal restored by this frequency filtration: s(t) = T^22n X J Ssarnpled (J)h(t — j)dj

— O

O 00

T f V 2

J > snS(t — nT) x

-2n

-m n=-m

sin D( t — t)

-2n

dT

D(t — t)

m m

TD V f

= - >sn J S(r

■nT)

n=-œ -m

sin D( t — t)

dT

D(t — t)

m

T^ ^ . sin(D( t — nT))

T D V"1 :

= — > s(n T)-

D(t — nT)

In order to avoid the imposition of spectra T < - is necessary. This is the mathematical formulation of the Kotelnikov theorem.

a) Signal s(t) and restored s*(t)

J22n ' Ht

This filter is called "ideal low pass filter" or "sinc-filter" because of sinc-function (s inc(x) = -j"). Unfortunately, it couldn't be realized in practice - because it is infinite in time (in the future and in the past).

Spectra multiplication is equivalent to signal convolution:

0

S((JQ) = F((o)G(CD) ^ 5(0 = -L J S (d))ei^du

VZn J

-0

0

= J F ((o)G (CD)ei^du 422R J

s(t)

sinc(t-0)

sinc(t-0.25)

sinc(t-0.5)

sinc(t-0.75)

sinc(t-1)

sinc(t-1.25)

sinc(t-1.5)

sinc(t-1.75)

sinc(t-2)

sinc(t-2.25)

sinc(t-2.5)

sinc(t-2.75)

sinc(t-3)

s (t)

restored

samples

*

1

m

0

Time t, sec. b) Spectrums

S(f)

S (f)

Sinc H(f)

Frequency F, Hz

Fig. 5. The original continuous rectangular single pulse signal recovery from the samples: the original and reconstructed signal (a), the spectra of the original signal, the sampled signal and the filter (b). See Matlab code in Appendix E.

B. Restoring with not ideal low pass filter

An ideal low-pass filter (sinc-filter) is not physically realizable, since the sinc-function has non-zero values for all time points up to infinity, and the impulse response of an ideal filter is not zero for times less than zero. It can only be used mathematically.

For example, consider the signal restoration using the simplest low-pass filter - RC circuit from the article [1]

Fig. 6. RC circuit and its time and vector diagrams

0

3

2 _

0

-4

2

4

The amplification spectrum (dependence of the output voltage, that is, the capacitor on the input voltage for each individual frequency of the input signal) depends on the impedances:

1

h(cd ) = — = Zc = ^C = 1

Uin ZR + Zc R(1+j co RC) 1+ jœRC

Module (absolute value without phases) of this transfer characteristic:

iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.

\H(a>)\== 1

+ ( CO RC)2

a) RC-response H(w)=U

-40 -30 -20 -10 0 10 20 30 40

Frequency w, rad/sec

- H(w) angle

-40 -30 -20 -10 0 10

Frequency w, rad/sec

20 30

-40 -30 -20 -10 0 10

Frequency w, rad/sec

b) Spectrums

20 30

-10 0 10 Frequency w, rad/sec

_ S discrete (w)

- H(w)

--A V

-10 0 10 Frequency w, rad/sec

c) Restored signal

- s(t)

s ...... (t)

-5 -4 -3 -2 -1 0 1 2 3 4 5

Time t, sec

Fig. 7. The RC circuit can be used as a simple low pass filter: response spectrum (a) and a recovered sampled rectangular pulse

signal (b). See Matlab code in Appendix F.

It can be seen that although RC-circuit is not very good low-pass filter. The level of power decreasing by a factor of 2 (that is, the voltage amplitude V2 times lesser) is achieved at a frequency H = —, this can be considered as a conditional filtering boundary.

For recovery, we can also directly simulate the physical processes in the circuit over time. As discussed in the first part of the article series the currents and voltages are related:

iR( 0 =

E(t) - Uc(t)

= i c( 0 = c

d Uc ( t)

R C dt

So state changing depends on the current state:

d Uc( t) =

E(t) - Uc (t) RC

dt

We can assume the capacitor is initially discharged: U c (0) = 0.

Of course, it is also necessary to replace the abstract delta functions, for example, with a pulse of finite duration and value (so that their product is single). Also, the simulation time will not be continuous, but divided into many small steps.

Fig. 8. Physical modeling of RC-circuit processing of a sampled signal sequence. See Matlab code in Appendix G.

The principle of operation of the RC-circuit is clearly seen: each pulse of the comb, due to its very large value, very quickly affects the charge of the capacitor (raising it to a significant level). After that, the capacitor discharges more slowly (because of its accumulated voltage is less than prompting pulse) until the next correction pulse, which charges it again, and so on.

Although the signal differs from the original, but it still reminds him.

In practice, much better low-pass filters are used, which give a result quite close to a sinc-filter.

V. Discrete Fourier Transform - Discrete

SPECTRUM FOR A FINITE NUMBER OF SAMPLES

Summary, the spectrum of the sampled signal (peaks of the sequence of delta functions scaled to the samples values) is continuous, as is the original; and differs because of multiple copies at a distance corresponding to the time/sample rate.

From these samples, the original continuous signal can be accurately restored in some conditions.

But is it possible to discretize the spectrum so that it

40

40

20

30

40

4

represents only a set of samples also? In this case, we again will not have to deal with continuous functions and we will be able to process them on digital devices.

The spectrum can be calculated from the readings directly:

Ssarnplediw) = ~== J Ss(t)e-JMtdt

UJ 00

= f s(ü) V s(t - nT) e-'atdt 00

= -L V f s(t)<5(t - nT)e-JMtdt y2n J

n=-00 -0 0

= -= V s(nT)e->wnT Jin

1 V

= ^= / s„e

-]u>nT

^sampled

n=0

(2nk\ 1 v"1 S„ = s[—) =— V

\NTJ Jfr.

■in, „

s„e NT

jv — l

=V

s„e

-i(iPlkn

spectrum:

N-l

VSkßj

N-l /N-l \

_ V / V Srne-KW)km ) ejfkn

k=0

= I{I

k=0 \m=0

N-l N-l = VS™V

m=0 k=0

N-l 1

= Xs™ V['

ej1L(m-n)k =

ejlT(m-n)

k=0 '

ak

geometric progression sum

Sum of N numbers (0..N-1) of geometrical progression a in last equation is:

N-l I 1

Vak-

k=0

a N,

1

k = 1

■in, , „ [ 1 - eJ~N (m-n)xN

1 -a

iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.

0

N,

l

integer

1 - gjln (m-n)

a

= i

0,

N,

N,

m ± n m = n

m ± n m = n

m ± n m = n

So:

JV—± i V _L

lSke>fkn = Vsm X ß m = I =

N X s„

k=0

If the number of available samples is finite (for example, from 0 to N - that we always have in real world), we respectively change the limits of summation:

This pair of one-to-one transformations that bind a finite number of samples of a discretized signal and a discretized spectrum is called the Discrete Fourier transform (DFT) or Discrete in time Fourier transform.

■i{ir)kn

Consider for this case the spectrum samples Sk at some selected frequency points w = —:

=V

n=0 N-l

1 v-i .m. =1

They are interesting because of all the samples of the original sequence can be calculated only from them, without using all the other points and intervals of the continuous

k=0

That is, we can use not the entire continuous spectrum, but only a small set of fixed points in it (number is equals to number of time samples), applying transformations and filters only to them.

At the same time, for real-valued signals only one half of the spectral samples is sufficient for restoring due to the conjugate symmetry (exact equality of the i-th and (N-l)-th reference):

N-l

SN-k = y s„e

=V

■>N-k — / "n^ n=0

-j&f)(N-n)k =

S—6

N-l = Vs"e

n=0

V

n=0

+j&)kn = sk

-j2nk+j(jP)kn

Briefly Discrete Fourier transform also could be written in vector/matrix form:

S = Fs, where Fm

= e-^'N(m-l)(n-l)

S =

S3

S4

\sj

1 1 1 1

1 e-'lfXl e-fri . e-l%X(S-l)

1 e-'ifXi e-i2-WX8 . , e-'TfX1 (N-l)

1 e -j1fx(N-l) e-'TrX1 (N-l) . . e-lwX(N-l)(N-l)/

\(SsW

\sN/

a) Signal s(t) = rectangularPulse(0, 1, t)

/ VI \l \l \l \l \1 \/ \l \

\ 1

0 0.5

Time, t (sec)

-Signal s(t)

* S""p'" s n

-^ Sampled s (t)

Appendix A. Dirac Comb spectrum calculations

D(m) = -iL Y e-'amT = {q12 = e±'<"T] ■JTM ¿—> '

1

' fin

I«" + 1

2

G e ometrical Ge o metrical progress ion 1, progression 2, ■ Positive k Negative k

Correspond to k=0

b) Spectrum S(w) vs FFT

4 5

Frequency, f (Hz)

Geometrical progression partial sum:

-1

=

k=0

q = 1 ^ e±i0lT = 1 ^ oT = 2nr, rEl q* 1

,

=

U ~q '

Fig. 9. Comparison of spectra: a continuous signal of a rectangular pulse and sampled spectrum frequencies of a sampled signal. Signal and its discretization shown at (a), and signal spectrum in comparison with DFT. One can see the symmetry (redundancy) of the DFT and the deviation of the points of the spectrum of the discretized signal from the line of the spectrum of the continuous signal due to the imposition of copies. See Matlab code in Appendix H.

There are algorithms that allow to find these spectral samples very quickly Fast Fourier Transform (FFT). The number of operations in them can be proportional to N log N for the number of samples N. They are implemented in various software products as standard functions [8].

VI. Conclusion

Thus, a continuous signal (if it's spectrum can be limited by acceptable bounds) can be turned into a set of samples, from which it can then be restored (if necessary or after processing). The number of samples directly depends on the selected boundaries of the used signal spectrum.

Moreover, for practical purposes the number of samples will be finite, which means that a finite number of samples of the sampled signal spectrum can be stored or processed.

Therefore, continuous signals of the real world can be turned into sets of numbers and processed by digital computing devices, as well as transmitted between them by any convenient means, including those with suitable modulation and at suitable frequencies. That is the theme of the next part of article series.

This sum sequence doesn't convergent in the usual sense because of infinite oscillating. In this cases under the limit could be understood Cesaro summation (as limit of average partial sum):

rn N N n

ZC esaro 1 V""1 1 V""1 V""1

an = A < > A = lim — / Sn = lim — > > i n n^^nl-i n n^ni-Ii-I

k=l n=l n=lk=l

For the case of discussed sequence:

N Z'

^1

2 J N+1

ù)T = 2nr

-1

1 - e±i">Tn

nZ-i 1 - e±iT ' =1

iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.

Separately operating for case co T * 2nr: 1 =1 y 1 -gn = 1

N '

e lse

Sn NA, 1 -q N(1 - q) =1

-

n=l

\ Geometrical f

\ proaression h'

(1 - ) 1

-

progression 3'

1 - qN-1 1-q

1 -q ' q~N(1 - q)2 The limit for each progression is:

\ Pa rtial s u m of 3/ 1 - -1

lim1 Yi

n^^nz-i

N + 1

lim-= m,

n^ 2 ,

1 11- qN-1

-- lim — x -

(1 - q ) n^N (1-q)2 (1 - e±^'T )'

ù) T = 2nr

els e

The limit of sum of Geometrical progressions 1 and 2:

lim (N + 1) = m, o>T = 2nr

e lse

Separately operating for case ai T * 2nr:

+

1 _(1 - e-jœT) + (1 - eJœT) (1 - e ¡œT ) ' (1 - e-iœT ) = ~{-—eiœF)(--—ezJœF)'

2 - (e>œT + e-'œT) " 1 - e-jœT _ ejut + eo

1

2 - (e'°'T + e->°>T)

2 - (eiœT + e-iœT)

=1

So,

y—j œ nT

j2n = l 0,

lim -1 (S,

1 + S2) - 1

lim

N-

=l

(¡0 T = 2 nr els e

Let explore integral in some range around some point coT = 2 nr,r E Z:

^ e-i°mT I dco

f D(ùj)dM = vfe f (

2f(r—1/2) 2T(r—1/2)

22T(r+1/2)f „ „

1 f leJqT + Z

n=1__n=1__

\ Positive n Negative n

\

' -ja

2\r—1/2) "=1

•jomT

Correspond to n=0

dut

1

' j2n

'

f(r+1/2)

j2n

1 f (e'œnT + e—JœnT)dù t (

fr

n=122^(r+1/2) "(r+1/2)

2T(r+1/2)

2~(r+1/2)

j2n

1f

hr—V2)

, ^ 2n

cos(ü)nT) T

---dM + —?=

2

:mL èT{™ (T (r+1/2)nT)

n=1

- sm yy (r- 1/2)nT)) _ V22n

= ~ 00

+ —^ Y-(sm(2nnr + nn)

v^ti —1

— sm22nnr — nn) \ =

' 0 '

That is, the area (integral) of the function in a neighborhood of points where it is nonzero is finite. So, this is a scaled delta function:

rn -- rn

D(oj) = vkYe-1WnT = Yn)

n=-tn n=-&i

B. Matlab code: Sampling example (Figure 1)

% Sampling singnal examle %% Settings

s = @(t) rectangularPulse(0, 2, t); % signal func

Tmax = 3; dt = 1/5; accuracy = 500;

max plot time samplting time continuous time steps

ones-vector timeline to

%% Processing e = @(t) ones(size(t)); timeline = linspace(0, Tmax, 500); plot

t_samples = 0:dt:Tmax; % sampling timeline

%% Plotting figure();

% plot signal

subplot(2, 2, 1); hold on; grid on;

title('a) Signal continuous s(t)'); xlabel('Time, t'); ylabel('Value'); axis([0 Tmax -0.5 1.5]);

plot(timeline, s(timeline), 'DisplayName', 's(t) signal');

iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.

% plot signal

subplot(2, 2, 2); hold on; grid on;

title('b) Signal values s(nT)'); xlabel('Time, t'); ylabel('Value'); axis([0 Tmax -0.5 1.5]);

scatter(t_samples, s(t_samples), '*', 'DisplayName', 's(t) signal');

% plot comb

subplot(2, 2, 3); hold on; grid on;

title('c) Sampling comb d(t)'); xlabel('Time, t'); ylabel('Value'); axis([0 Tmax -0.5 1.5]);

stem(t samples, e(t samples), 'DisplayName', 'sampling');

% plot samples

subplot(2, 2, 4); hold on; grid on;

title('d) Sampled signal s_{sampled}(t)'); xlabel('Time, t'); ylabel('Value'); axis([0 Tmax -0.5 1.5]);

stem(t_samples, s(t_samples), 'DisplayName', 's_sampled');

C. Matlab code: Dirac comb visualization (Figure 2)

% Sampling comb visualization

%% Settings

Tmax = 5; % max plot time, sec

Fmax = 5; % max plot frequency, Hz

dt = 1/2; % sampling time, sec

%% Processing

e = @(t) ones(size(t)); % ones-vector

Wmax = 2*pi*Fmax; % max plot freq., rad/s

dw = 2*pi/dt; % sampling freq., rad/s

Nt = floor(Tmax/dt); % number of t-samples

Nw = floor(Wmax/dw); % number of w-samples

t samples = dt*[-N t:N t] % sampling timeline

w samples = dw*[-N w:N w] % sampling freq.line

D scale = sqrt(2*pi)/dt ; % frequency scaling

%% Plotting

figure();

% plot signal

subplot(2, 1, 1); hold on; grid on;

+

title('a) Time sampling d(t)'); xlabel('Time t, sec.'); ylabel('Value'); axis([-Tmax Tmax -0.5 1.5]);

stem(t_samples, e(t_samples), 'DisplayName', 'Time comb d(t)'); _

text(dt, 1+0.1, '1', 'HorizontalAlignment', 'center', 'VerticalAlignment', 'bottom'); text(dt/2, -0.3, 'T', 'HorizontalAlignment', 'center');

line([0 0],[0 -0.3], 'Color', 'r', 'LineStyle','');

line([dt dt],[0 -0.3], 'Color', 'r', 'LineStyle','-');

line([-.1 dt+.1],[-.2 -.2], 'Color', 'r', 'LineStyle','-');

line([-.05 .05],[-.2-.05 -.2+.05], 'Color', 'r', 'LineStyle','-');

line([dt-.05 dt+.05],[-.2-.05 -.2+.05], 'Color', 'r', 'LineStyle','-');

% plot spectrum

subplot(2, 1, 2); hold on; grid on;

title('b) Frequency sampling D($\omega$)'); xlabel('Frequency $\omega$, rad/sec.'); ylabel('Value');

stem(w samples, D scale*e(w samples), 'DisplayName', 'Frequency comb d(t)');

text(dw+0.4, D_scale-0.2, '${\sqrt{2\pi}}\over{T}$');

text(dw/2, D_scale*-0.3, '${2\pi}\over{T}$', 'HorizontalAlignment', 'center'); line([0 0],[0 D_scale*-0.3], 'Color', 'r', 'LineStyle','-');

line([dw dw],[0 D_scale*-0.3], 'Color', 'r', 'LineStyle','-');

line([D_scale*-.1 dw+D_scale*.1],[D_scale*-.2 D scale*-.2], 'Color',_'r', 'LineStyle','-'); line([D_scale*-.05 D_scale*.05],[D_scale*(-.2-.05) D_scale*(-.2+.05)], 'Color', 'r', 'LineStyle','');

line([dw-D scale*.05 dw+D scale*.05],[D scale*(-.2-.05) D_scale*(-.2+.05)], 'Color', 'r', 'LineStyle','-');

% Interpreter for special symbols set(groot,'defaulttextinterpreter','latex'); set(groot, 'defaultAxesTickLabellnterpreter', 'latex ');

set(groot,'defaultLegendlnterpreter','latex'); set(findall(gcf, '-

property','FontSize'),'FontSize',10)

D. Matlab code: sampled signal spectrum visualization (Figure 3)

%% Parameters pulse_start = 0; pulse duration = 1;

N_samples = 10; % number of samples

t min=0; % min t of a signal

t_max=3; % max t of a signal

% sampling time t step = t max/N samples; % sampled timeline

t_dicrete = linspace(t_min, t_max, N_samples); % max time to plot signal t plot max=5; % timeline to plot signal

t_plot_range = linspace(t_min, t_plot_max, N_samples*100);

% max frequency to plot w_plot_max = 2*(2*pi)/t_step;

% min frequency to plot w_plot_min = -w_plot_max; % frequency line to plot w plot range = w plot min:(w plot max-w_plot_min)/10 0 0:w_plot_max; % zero-division fix

w_plot_range(find(w_plot_range==0))=0.0 01;

% max frequency for IFT w_max = 2*pi/(2*t_step); % min frequency for IFT w_min = -w_max; % sampling frequency w_step = 2*pi/t_max; % sampled frequenct line

w_dicrete = linspace(w_min, w_max, N_samples+3);

% symbolic variables: time, frequency syms t w;

symbolic function of s(t) s function =

rectangularPulse(pulse_start,pulse_duration,t);%

%% Processing

o = @(t) zeros(size(t)); % zero-vector

e = @(t) ones(size(t)); % ones-vector

% signal

s continuous = eval(subs(s function, t, t_plot_range)); % samples

s_samples = eval(subs(s_function, t, t_dicrete)); % sampled signal

s_dicrete_function = sum((s_samples).*dirac(t-t_dicrete)) ;

% Spectrum - symbolic S_function = fourier(s_function); % Spectrum - array for plot S_continuous = eval(subs(S_function, w, w plot range));

% Spectrum discrete - symbolic

S_dicrete_function = fourier(s_dicrete_function); % Spectrum discrete - array for plot normalized S_dicrete = eval(subs(S_dicrete_function, w, w_plot_range))*t_step;

s restored function = ifourier(S disdis function, t);

s_restored = eval(subs(s_restored_function, t, t_plot_range));

yscale=ceil(max(abs(S dicrete)));

%% a) Signal continuous figure(1); grid on; hold on; axis([-1 t plot max -0.5 1.5]);

title(['a) Signal s(t) = ' char(s_function) ', and sampling $s_n$']); xlabel( 'Time, t (sec)'); ylabel('s(t)');

% Signal

plot(t plot range, s continuous, 'LineWidth', 2, 'DisplayName', 'Signal s(t)');

% Sampling

scatter(t dicrete, s samples, '*', 'k', 'DisplayName', 'Samples $s_n$'); quiver(t_dicrete, o(t_dicrete), o(t_dicrete), s_samples, 0, 'k', 'DisplayName', 'Sampled $s {sampled}(t)$');

% Restored

plot(t_plot_range, real(s_restored), 'Color', [.7 .7 .7], 'DisplayName', 'Restored $s {restored}(t)$');

legend('Location', 'best');

%% b) Signal spectrum -% 3D

figure(2); grid on; hold on; xlim([w_plot_min w_plot_max]); view(55, 25);

title(['b) Spectrum of a signal $S(\omega)$=' char(S_function)]);

xlabel('Frequency $\omega$, rad/s'); ylabel('Re $S(\omega)$'); zlabel('Im $S(\omega)$');

plot3(w_plot_range, real(S_continuous), imag(S_continuous), 'k'); % 3D curve plot3(w plot range, real(S continuous), -e(w_plot_range), 'r'); % Re

plot3(w_plot_range, 1.5*e(w_plot_range), imag(S_continuous), 'b'); % Im

% 2D

figure(3);

xlim([w_plot_min w_plot_max]);

subplot(3, 1, 1); grid on; hold on;

iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.

xlabel('Frequency $\omega$, rad/s'); ylabel('Re / Im');

plot(w_plot_range, real(S_continuous), 'r'); % Re plot(w_plot_range, imag(S_continuous), 'b'); % Im

legend('Re S(w)', 'Im S(w)' );

subplot(3, 1, 2); grid on; hold on; xlabel('Frequency $\omega$, rad/s'); ylabel( 'Abs S(w)');

plot(w_plot_range, abs(S_continuous), 'm'); % Abs

subplot(3, 1, 3); grid on; hold on; xlabel('Frequency $\omega$, rad/s'); ylabel( 'Anlge S(w)');

plot(w_plot_range, angle(S_continuous), 'g');% Ang

%% Spectrum of signal dicrete

figure(4);

grid on; hold on;

xlim([w_plot_min w_plot_max]); view(55, 25);

title('c) Spectrum $S_{sampled}(\omega)$ of sampled signal $s n$'); xlabel('Frequency $\omega$, rad/s'); ylabel('Re $S(\omega)$'); zlabel('Im $S(\omega)$');

plot3(w_plot_range, real(S_dicrete), imag(S_dicrete), 'k'); % 3D curve plot3(w_plot_range, real(S_dicrete), -e(w plot range), 'r'); % Re plot3(w_plot_range, 1.5*e(w_plot_range), imag(S_dicrete), 'b'); % Im

figure(5);

% Re - Im subplot(3, 1, 1); grid on; hold on; xlim([w_plot_min w_plot_max]); ylim([-yscale yscale]);

xlabel('Frequency, $\omega$ (rad/s)'); ylabel('Re / Im $S_{sampled}(\omega)$');

plot(w_plot_range, real(S_dicrete), 'r'); plot(w_plot_range, imag(S_dicrete), 'b');

line([2*pi/(2*t_step) 2*pi/(2*t_step)], [min(ylim)

max(ylim)], 'Color', 'k', 'LineWidth', 2); line([-2*pi/(2*t_step) -2*pi/(2*t_step)], [min(ylim) max(ylim)], 'Color', 'k', 'LineWidth', 2);

% Abs

subplot(3, 1, 2); grid on; hold on; xlim([w plot min w plot max]); ylim([-yscale yscale]);

xlabel('Frequency $\omega$, rad/s'); ylabel( 'Abs S(w)');

plot(w_plot_range, abs(S_dicrete), 'm'); % Abs

line([2*pi/(2*t step) 2*pi/(2*t step)], [min(ylim) max(ylim)], 'Color', 'k', 'LineWidth', 2); line([-2*pi/(2*t_step) -2*pi/(2*t_step)], [min(ylim) max(ylim)], 'Color', 'k', 'LineWidth', 2);

% Angle

subplot(3, 1, 3); grid on; hold on; xlim([w_plot_min w_plot_max]);

xlabel('Frequency $\omega$, rad/s'); ylabel( 'Anlge S(w)');

plot(w_plot_range, angle(S_dicrete), 'g'); % Ang.

line([2*pi/(2*t_step) 2*pi/(2*t_step)], [min(ylim) max(ylim)], 'Color', 'k', 'LineWidth', 2); line([-2*pi/(2*t_step) -2*pi/(2*t_step)], [min(ylim) max(ylim)], 'Color', 'k', 'LineWidth', 2);

%% dicrete spectrum of disceted signal

figure(6);

grid on;hold on;

xlim([w_min w_max]);%ylim([-yscale yscale]);

title('d) Sampled spectrum of sampled signal'); xlabel('Frequency, w (rad/s)'); ylabel('Re Sd(w), Im Sd(w)');

% dicrete spectrum of dicrete function S samples = eval(subs(S dicrete function, w, w_dicrete))*t_step; % samples normalized S_disdis_function = sum((S_samples).*dirac(w-w_dicrete))*2;

% Re-Im

plot(w_plot_range, real(S_dicrete), 'Color', [1 0.7 0.7]); _ _

plot(w_plot_range, imag(S_dicrete), 'Color', [0.7 0.7 1]); " "

quiver(w_dicrete, o(w_dicrete), o(w_dicrete), real(S_samples), 0, 'r');

quiver(w dicrete, o(w dicrete), o(w dicrete), imag(S_samples), 0, 'b');

%% Design: total

set(groot, 'defaulttextinterpreter', 'latex'); set(groot,'defaultAxesTickLabellnterpreter','latex ' );

set(groot,'defaultLegendlnterpreter','latex'); set(findall(gcf, '-

property','FontSize'),'FontSize',10)

E. Matlab code: signal restoring from the samples (Figure 4)

%% Parameters syms t w;

= rectangularPulse(0, 2, t); % signal sym func

Tmax = 3; % max plot time

Fc = 2; % sampling freq.

% Processing o = @(t) zeros(size(t)); % zero-vector

Wc = 2*pi*Fc; % sampling angular freq.

dt = 1/2/Fc; % sampling time step

dw = 1/dt; % sampling frequency step

N = Tmax/dt; % number of samples

Mmin = 0; % samples start

Mmax = Tmax/dt; % sampled finish

t samples = dt*[Mmin:Mmax]; % sampling timeline

plot timeline t_plot = linspace(-Tmax, Tmax, 500);

plot frequency-line f_plot = linspace(-3*Fc, 3*Fc, 500);

Spectrum - array for plot Sw = eval(subs(fourier(s), w, 2*pi*f plot));

samples

s_samples = eval(subs(s, t, t_samples));

sampled signal s dicrete function = sum((s samples).*dirac(t-t_samples));

Spectrum discrete - symbolic S dicrete function = fourier(s dicrete function);

Spectrum discrete - array for plot normalized S_dicrete = eval(subs(S_dicrete_function, w, 2*pi*f_plot))*dt; _ _

%% Spectrum

figure();

hold on; grid on;

title('b) Spectrums') ; xlabel('Frequency F, Hz'); ylabel('Spectrum value') ;

plot3(f_plot, real(Sw), imag(Sw), 'k', 'DisplayName', 'S(f)');

plot3(f_plot, real(S_dicrete), imag(S_dicrete), 'r', 'DisplayName', 'S {discrete}(f)'); plot([-3*Fc -Fc -Fc Fc Fc 3*Fc], [0 0 max(real(Sw)) max(real(Sw)) 0 0], 'b', 'DisplayName', 'Sinc H(f)');

legend('Location', 'best');

%% Signal figure(); hold on; grid on;

title('a) Signal s(t) and restored s*(t)'); xlabel('Time t, sec.'); ylabel('Value') ;

plot(t_plot, eval(subs(s, t, t_plot)), 'k', 'LineWidth', 2, 'DisplayName', 's(t)'); % signal

x = o(t_plot); for i=Mmin:Mmax

f = eval(subs(s, t, dt*i))*sinc(Wc*(t_plot-dt*i)/pi); " x = x+f;

plot(t_plot, f, ':', 'DisplayName', strcat('sinc(t-', num2str(dt*i),')')); end

plot(t_plot, x, 'r', 'LineWidth', 2,

'DisplayName', 's_{restored}(t)');

scatter(t_samples, eval(subs(s, t, t_samples)), '*', 'DisplayName', 'samples');

Ilegend('Location', 'northwest') ;

F. Matlab code: RC-response spectrum (Figure 5)

% RC response spectrum

%% Signal parameters syms t;

s = rectangularPulse(0, 2, t); % signal sym. Func. Tmax = 3; % max plot time

Fc = 2; % sampling freq.

%% Frequencies plot parameters f0 = -5; % show frequency from, Hz

f1 = 5; % show frequency to, Hz

steps = 1000; % frequency accuracy step

%% RC-circuit parameters R = 100; % R = 100 Om

C = 5e-3; % C = 5 mF

%% Processing response

% frequency line

w = 2*pi*linspace(f0, f1, steps); % cutoff frequency w0 = 1/R/C;

% response function H = @(w) 1./(1+j*w*R*C); % response vector H_C = H(w);

e = @(t( ones(size(t));

% zero-vector

%% Processing signal spectrum

t_plot = linspace(-Tmax, Tmax, 500); % timeline

iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.

dt = 1/2/Fc; % sampling time step

t_samples = dt*[0:Tmax/dt]; % sampling timeline

S_continuous = eval(fourier(s));% Spectrum array

s_samples = eval(subs(s, t, t_samples)); % samples s_discrete_function = sum((s_samples).*dirac(t-t_samples)); % sampled signal

% Spectrum discrete symbolic S_discrete_function = fourier(s_discrete_function); % Spectrum discrete

S discrete = eval(S discrete function)*dt;

%% Spectrum figure();

subplot(2, 1, 1); hold on; grid on;

title( 'b) Spectrums') ; xlabel('Frequency w, rad/sec'); ylabel('Re'); zlabel('Im');

plot3(w, real(S_continuous), imag(S_continuous), 'k', 'DisplayName', 'S(w)'); _

plot3(w, real(H(w).*S_discrete), imag(H(w).*S discrete), 'r', 'DisplayName', 'S_{restored}(w)');

legend('Location', 'best');

subplot(2, 1, 2); hold on; grid on;

xlabel('Frequency w, rad/sec');

ylabel('Re');

zlabel('Im');

plot3(w, real(S_discrete), imag(S_discrete), 'm', 'DisplayName', 'S_{discrete}(w)');

plot3(w, real(H(w)), imag(H(w)), 'b', 'DisplayName', 'H(w)');

legend('Location', 'best');

%% Plotting 2D figure();

% Abs subplot(3, 1, 1); hold on; grid on;

title('a) RC-response H(w)=U c/U'); xlabel('Frequency w, rad/sec'); ylabel('|H(w)|');

plot(w, abs(H C), 'DisplayName', 'H(w) stem([-w0 w0], [power(2, -1/2) power(2, 'filled', 'DisplayName', 'w {cutoff}'); abs' ) ; -1/2)],

legend('Location', 'best');

% Abs subplot(3, 1, 2); hold on; grid on;

xlabel('Frequency w, rad/sec'); ylabel('angle, rad/sec');

plot(w, angle(H C), 'DisplayName', 'H(w) angle'); stem([-w0 w0], [angle(H(-w0)) angle(H(w0))], 'filled', 'DisplayName', 'w {cutoff}');

legend('Location', 'best');

% Re, Im subplot(3, 1, 3); hold on; grid on;

xlabel('Frequency w, rad/sec'); ylabel('Re, Im');

plot(w, real(H C), 'DisplayName', 'H(w plot(w, imag(H C), 'DisplayName', 'H(w stem([-w0 w0],_[real(H(-w0)) real(H(w0 'filled', 'DisplayName', 'w {cutoff}') stem([-w0 w0], [imag(H(-w0)) imag(H(w0 'filled', 'DisplayName', 'w {cutoff}') real' ) ; imag') ; )], )],

legend('Location', 'best');

G. Matlab code: RC-circuit signal restoring (Figure 6)

%% Time parameters

T_start = 0; % start time, sec

T_end = 3; % finish time, sec

% continuous time accuracy step dt continuous = (T end-T start)/1000;

F sampling = 2;

%% RC parameters R = 100; C = 5e-3;

sampling frequency, Hz

2 Om 5 mF

%% Signal parameters syms t;

U symbolic = rectangularPulse(0, 2, t); % signal

delta_duration = dt_continuous*5; % delta-impulse delta_value = 1/delta_duration;

%% Processing signal % timeline

t_continuous = T_start:dt_continuous:T_end; % null time vector o = @(t) zeros(size(t));

dt_sampling = 1/2/F_sampling; t_samples = T_start:dt_sampling:T_end; N_samples = (T_end-T_start)/dt_sampling;

U_continuos = eval(subs(U_symbolic, t, t_continuous));

U samples = eval(subs(U symbolic, t, t samples));

%% Real delta-output U_out = o(t_continuous); % Scaled delta grid for i=0:N samples

current_time = i*dt_sampling; U_sample = eval(subs(U_symbolic, t, current_time));

U out = U out + U_sample*delta_value*rectangularPulse(current_time , current_time+delta_duration, t_continuous); end

%% Processing CR-circuit: step-by-step modeling U_C = (0);

for i = 1:size(U_out, 2)-1

dUC = (U out(i)-U C(i))/R/C*dt continuous; U_C(i + 1) = U_C(i)+dU_C;

end

%% Processing sinc-filter % W_sampling = 2*pi*F_sampling; U_LPF = (0); for i=1:size(U_out, 2)

current_time = i/2/F_sampling;

f = eval(subs(U symbolic, t, current time)) * sinc(2*F_sampling*(t_continuous-current_time)); U_LPF = U_LPF + f; _

end

%% Plot a: RC modeling voltage figure();

axis([T start T end -1 max(U C)+1]); % subplot(2, 1, 1); hold on; grid on;

title('a) Voltages in RC-circuit'); xlabel('Time t, sec.'); ylabel('Voltages u(t), V' );

plot(t_continuous, U_continuos, 'DisplayName', 'U {continuous}');

stem(t_samples, U_samples, 'DisplayName', 'Samples');

plot(t_continuous, U_out, 'DisplayName', 'U {sampled}'); _

plot(t_continuous, U_C, 'DisplayName', 'U_{restored}'); % plot

voltage

plot(t_continuous, U_LPF, 'DisplayName',

'U {sinc}'); _ % plot

voltage

legend('Location', 'best');

H. Matlab code: comparing continuous spectrum and DFT (Figure 7)

figure('units','normalized','outerposition',[0 0 0.5 1]);

%% Parameters

symbolic variable

%Signal

syms t; % t

% symbolic signal t

s_function = rectangularPulse(0, 1, t); % Symbolic expression, Fourier function S function = fourier(s function);

% Time parameters N_counts = 20; N_plot = 500;

number of samples plot accuracy

Tmax=2; % plotting start time

Tmin=0; % plotting end time

%% Processing

% sampling time step

dt = (Tmax-Tmin)/N_counts;

% plot timeline

t_plot = linspace(Tmin, Tmax, N_plot);

% sampling timeline

t_samples = dt*(0:N_counts-1);

o = @(t) zeros(size(t)); % zero-vector

%% Fourier processing

% Plot frequency line

f_plot = linspace(-1/dt, 1/dt, N_plot); f_plot(f_plot==0)=0.0 0 01; % zero-division fix

% Sampling frequencies

f_samples = linspace(0, 1/dt, N_counts); f_samples(f_samples==0)=0.0 0 01;% zero-disivion fix

% Evaluate symbolics spectrums

% Continuous w = 2*pi*f_plot;

S_continuous = eval(S_function);

iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.

% Spectrum samples w = 2*pi*f_samples; S_samples = eval(S_function);

% Signal sampled

s_sampled = eval(subs(s_function, t, t_samples));

%% Signal plot

subplot(2, 1, 1); grid on; hold on;

title(['a) Signal s(t) = ' char(s_function)]);

xlabel( 'Time, t (sec)');

ylabel('s(t)');

% signal

plot(t_plot, eval(subs(s_function, t, t_plot)), 'k');

% samples

scatter(t_samples, s_sampled, '*', 'k'); % sampled signal

quiver(t_samples, o(t_samples), o(t_samples), s_sampled, 0, 'm');

legend('Signal s(t)', 'Samples s_n', 'Sampled s_{sampled}(t)');

%% Plot spectrums subplot(2, 1, 2); grid on; hold on;

% FFT plotting

fft_S = fft(s_sampled)/N_counts*2; % Normalization

scatter(f_samples, real(fft_S), '*', 'r'); % Re

scatter(f_samples, imag(fft_S), '*', 'b'); % Im

% Symmetry line

plot([1/2/dt 1/2/dt], [-1 1], 'k');

legend( ' Re S (w) ' , 'Im S (w) ' , 'Re FFT', 'Im FFT',

'FFT simmetry line');

References

[1] E. Tikhonov, M. Sneps-Sneppe. "Introduction to signal processing: sine wave and complex signals", International Journal of Open Information Technologies, Vol. 7, No 3, March 2019, ISSN 23078162.

[2] E. Tikhonov, M. Sneps-Sneppe. "Introduction to signal processing: spectral representation", International Journal of Open Information Technologies, Vol. 7, No 4, April 2019, ISSN 2307-8162.

[3] Lyons, Richard G., "Understanding digital signal processing", 3rd ed., Library of Congress Cataloging-in-Publication Data, 1948, ISBN 013-702741-9

[4] Kotelnikov VA, "On the transmission capacity of "ether" and wire in electrocommunications", (English translation, PDF, url: http://ict.open.ac.uk/classics/Lpdf), Izd. Red. Upr. Svyazzi RKKA (1933), Reprint in Modern Sampling Theory: Mathematics and Applications, Editors: J. J. Benedetto und PJSG Ferreira, Birkhauser (Boston) 2000, ISBN 0-8176-4023-1

[5] Robert J. Marks II, Introduction to Shannon Sampling and Interpolation Theory, Springer-Verlag, New York, 1991. Available: https://marksmannet.com/RobertMarks/REPRINTS/1999_Introductio nToShannonSamplingAndInterpolationTheory.pdf. Retrieved: May, 2019

[6] Kharkevich A.A., "Essays on the general theory of communication" (Russian), State publishing house of technical and theoretical literature, Moscow, 1955

[7] Ilyin V.A., Sadovnichy V.A, Sendov Bl.H. "Real Numbers // Mathematical Analysis" (Russian), 3rd ed. pererab. and add. / Ed. Tikhonov A. N., Prospect, Moscow 2006, ISBN 5-482-00445-7

[8] Emmanuel C. Ifeachor (2011) "Digital Signal Processing A practical approach download". Prentice Hall; 2 edition (October 7, 2001), ISBN-10: 9780201596199

xlim([-1 1/dt]); % limited axes

title('b) Spectrum S(w) vs FFT'); xlabel('Frequency, f (Hz)') ; ylabel('Re S(f), Im S(f)' );

% Spectrum

plot(f_plot, real(S_continuous), 'r'); plot(f_plot, imag(S_continuous), 'b');

i Надоели баннеры? Вы всегда можете отключить рекламу.