Вы находитесь на странице: 1из 13

Chapter 3 Matlab Simulations

Chapter 3 Matlab Simulations.............................................................................................1 3.1 Introduction....................................................................................................................2 3.1.1 Introduction to Matlab............................................................................................2 3.1.2 Modules for Simulation..........................................................................................2 3.2 Coding............................................................................................................................4 3.2.1 Flow chart (If possible)...........................................................................................4 3.2.2 Simulations.............................................................................................................4 3.2.2.1 Comparison of multiplexing strategies............................................................4 3.2.2.2 Comparison of different coding strategies.......................................................4 3.2.2.3 Protocol testing................................................................................................4 3.2.2.4 Any more if there are...................................................................................4 3.3 Channel..........................................................................................................................5 In order to transmit, it is significant to simulate the channel. Wireless channels are impaired by fading and noise which will be simulated here separately along with their flowcharts.........................................................................................................................5 3.3.1 Flowchart of Fading ...............................................................................................5 3.3.2 Simulation of Fading...............................................................................................6 3.3.3 Gaussian Noise..................................................................................................11 Figure 6: Noise simulation flow chart...........................................................................11 3.3.4 Simulation of Gaussian Noise...........................................................................11 3.4 Modem.........................................................................................................................13 3.4.1 Flow chart.............................................................................................................13 3.4.2 Simulation.............................................................................................................13 3.5. Integration...................................................................................................................13 3.6 Diversity.......................................................................................................................13

3.1 Introduction
In this chapter, simulations are going to be discussed. Every block or part will be separately tested, analyzed and presented here. The language of technical computing Matlab is used for the simulations. The flowcharts for the matlab codes of these simulations will be shown for better and easy understanding of the codes. The codes are placed in the appendices for later reference.

3.1.1 Introduction to Matlab


Matlab for technical computing and Simulink (another component of Matlab package) are the communications industry standards. Todays communication industry is using MathWorks tools and communications engineers rely on MathWorks in increasingly complex research. We are using technical computing part of MathWorks for the simulation of different parts of robust communication system. To clear again as done in Chapter 1, our focus is not the design of this hardware system rather is on channel investigation, modem and coding techniques.

3.1.2 Modules for Simulation


The simulation consists of eighteen files. The main file is principa10.m which includes the main code and calls to different other files and functions. This makes the programming code simple and understandable. The other seventeen modules are as follows: Questionfun.m Dopplarfading.m Generfun.m

Mux.m Protocfun.m Modulation_Simu.m AWGNChannel.m Demodulation_Simu.m o Diversity.m Decodefun.m Deprotocfun.m Demodulation_Simu14.m o Diversity14.m Plot_AWGN_Sample1_Code1_Diver.m Plot_AWGN_Samples_1510.m principa11.m principa12.m

The Questionfun.m module asks questions to the user about the choices of way of multiplexing, coding technique, the time of observation and diversity technique. Dopplarfading.m module generates flat Rayleigh complex fading and stores it in the matrix. Generfun.m generates the data which will be positions for our case to be transmitted. Mux.m multiplexes the data in chosen way. Protocfun.m places the data frame in the protocol. Modulation_Simu.m modulates the signal. AWGNChannel.m generates complex AWGN noise. Demodulation_Simu.m demodulates the signal and calls Diversity.m which uses diversity technique. Decodefun.m decodes which is comparing the redundant data and choosing the best one. Deprotocfun.m removes the protocol flags, counters and repetition bits. Have to discuss last six files

3.2 Coding
3.2.1 Flow chart (If possible) 3.2.2 Simulations
3.2.2.1 Comparison of multiplexing strategies 3.2.2.2 Comparison of different coding strategies 3.2.2.3 Protocol testing 3.2.2.4 Any more if there are

3.3 Channel
In order to transmit, it is significant to simulate the channel. Wireless channels are impaired by fading and noise which will be simulated here separately along with their flowcharts.

3.3.1 Flowchart of Fading


This channel is affected by Rayleigh fading due to Doppler Effect as described in chapter 2. The simulation of Rayleigh fading channel was done by Smiths model. A block diagra m of Smiths method is shown in figure 1:

[2]

Figure 1: Smiths model N (0, ) shows two normally distributed generators with mean zero and standard deviation sigma. Ak and Bk are the zero mean Gaussian sequences in frequency domain which are multiplied with Fk. Fk are the filter coefficients and in our case they are the square root of sampled power spectral density of Rayleigh distribution. K represents sequence and k is the index. One component is multiplied with -j to make it complex and then added as follows: Zk=FkAk-jFkBk After obtaining Zk its inverse Discrete fourier transform is taken. In Matlab this will be Inverse fast fourier transform (IFFT) and time domain representation will be obtained which is zk. In the last block, the absolute value is taken which is obtained as k .

3.3.2 Simulation of Fading


For simulation purposes, it is sufficient to consider baseband but it might not be sufficient for hardware implementation purposes. Therefore, the channel simulation was not made at carrier frequency which is 3.4 Ghz, if that was done then spectrum would be considerably trivial as most information would contain zeros instead of doppler spectrum. Lets simulate the flat Rayleigh fading process and noise for analysis. 3.3.2.1 Rayleigh fading The region where the gain is intensively negative dBs is known as deep fade. The distance between two deep fades is 44.1 ms as calculated in section 2.3.1, so there will be about 20 deep fades for 20 wavelengths. In other words, there will be three deep fades every 0.1s which is also depicted in the figure. In the figure 2, it can be seen that there are about 20 fades which correspond to 20 wavelengths.

Figure 2: Channel fading for velocity 1 m/s and wavelength 88.2 mm at baseband It would be possible to transmit without errors in the upper part of the figure where the gain is 0 dBs and above. This is the place where the multipath waves interfere constructively thus giving strength to the transmitted signal. As we go down, we approach to a place where the multipath waves start to interfere destructively and thus reducing the strength of the signal. The maximum depth of deep fade can be seen till about -50 dB and -30dB where burst of errors are to occur. To avoid this, we have used redundancy coding technique and diversity technique which will be analyzed in the further sections. For good computer based Rayleigh simulation, one percent cumulative samples from minimum should be approximately 20 dB. We tested our channel about 30 times and 25 times 1% cumulative level was in the range of -21 to -18.5 dB and rest of the times it was between -22 to 17 dB. 3.3.2.2 Phase jumps of fading In the following figure 3 the phase changes can be seen:

Figure 3: Illustration of jump of angle Figure 3 is illustrating the jump of angle for the fading shown above in figure 2. It can be seen that every deep fade there is a jump of angle of about a pi. This also verifies that the deep fade has an effect of changing the transmission by pi which results in strength loss of the signal thus causing errors to occur.

3.3.2.3 Verification of fading Amplitude

Theoretically the envelop of fading should follow the Rayleigh distribution and phase should be uniformly distributed over [-pi,pi) Refer to Chapter 2.

Figure 4: Illustration of fading amplitude following Rayleigh distribution It can be seen in figure 4 that for 9600 samples and observation time 400 seconds, the amplitude of fading follows Rayleigh distribution ideally.

3.3.2.4 Verification of fading phase In figure 5 it can be seen that the phase of fading is uniformly distributed from pi to pi as explained in theory. This verifies that our channel simulation is ideal. The [-pi,pi) is marked by a line in the figure 5 and given a name of reference value.

Figure 5: Phase verification The phase -pi is the same as pi in matlab, so the probability at two sides show half of the total probability.

3.3.3 Gaussian Noise


This channel is affected by Gaussian noise. It is very easy to simulate Gaussian noise in Matlab. The randn command was used to generate normally distributed noise as shown in the figure 6 below.

Figure 6: Noise simulation flow chart In the figure 6, there are two zero mean Gaussian generators. The non-complex part refers to the in-phase component of the noise and complex part refers to the quadrature component. Both components are at right angle to each other, therefore both of them will be normally distributed at right angles refer to section 3.3.2.2

3.3.4 Simulation of Gaussian Noise


Gaussian noise in time domain looks like random fluctuations with amplitude depending upon the power of noise. In the following figure 7, the complex Gaussian noise can be seen for 200 input samples. The input samples were taken as zeros to observe noise. If we consider the pdf of this noise, it follows Gaussian distribution.

Figure 7: Gaussian noise So, it can be seen that even if there is nothing transmitted the receiver might detect something which can cause errors. Modulation is used in order to handle this problem.

3.4 Modem
3.4.1 Flow chart 3.4.2 Simulation

3.5. Integration 3.6 Diversity

Reference: [1] http://www.mathworks.com/industries/comms/ [2] http://www.item.ntnu.no/~fli/TD-03-040_Ola.pdf

Вам также может понравиться