Question

In: Electrical Engineering

Matlab Explain the codes below % Jake.m % Generate a frequency selective fading function [r, iout,...

Matlab

Explain the codes below

% Jake.m

% Generate a frequency selective fading

function [r, iout, qout] = Jake(idata, qdata, nsamp, fs, fc, NN, N1_arr, velocity, counter_arr, delay_time, attn, flat)

%****************************** variables *******************************

% idata input Ich data

% qdata input Qch data

% nsamp Number of samples to be simulated

% fs Sampling frequency (Hz)

% fc Carrier Frequency (Hz)

% NN Number of paths

% N1 Number of waves in order to generate fading

% velocity Mobile speed in Km/h

% counter Fading counter

% delay_time Delay for each fading path (ns)

% attn Attenuation level for different fading paths (dB)

% flat flat fading or not

% r Envelope of fading channel complex impulse response

% iout output Ich data

% qout output Qch data

%************************************************************************

v = velocity./3.6; % m/s

c = 3e8;

fm = fc*v/c; % Maximum doppler frequency (Hz)

delay_samp = round(delay_time.*fs.*1e-9); % normalized delay time in number of samples

total_attn = sum(10.^(-1.0.*attn./10.0)); % normalize the power

tstp = 1/fs; % minimum time resolution

iout = zeros(1,nsamp);

qout = zeros(1,nsamp);

r = zeros(1,nsamp);

theta = zeros(1,nsamp);

for i=1:NN

atts = 10.^(-0.05.*attn(i)); % attenuation for current path

  

[itmp, qtmp] = delay(idata, qdata, nsamp, delay_samp(i));

[r_single, iout_single, qout_single] = fade2(itmp, qtmp, nsamp, tstp, fm, N1_arr(i), counter_arr(i), flat);

  

counter_arr = counter_arr+200; % update counter

  

iout = iout + atts.*iout_single./sqrt(total_attn);

qout = qout + atts.*qout_single./sqrt(total_attn);

  

end

r = sqrt(iout.^2+qout.^2);

Solutions

Expert Solution

I give the explaination in Bold and Italic:

this code genrate gfunction named Jake

the input to the functions are

% idata input Ich data

% qdata input Qch data

% nsamp Number of samples to be simulated

% fs Sampling frequency (Hz)

% fc Carrier Frequency (Hz)

% NN Number of paths

% N1 Number of waves in order to generate fading

% velocity Mobile speed in Km/h

% counter Fading counter

% delay_time Delay for each fading path (ns)

% attn Attenuation level for different fading paths (dB)

% flat flat fading or not

% r Envelope of fading channel complex impulse response

The output of the Functions

% iout output Ich data

% qout output Qch data

function [r, iout, qout] = Jake(idata, qdata, nsamp, fs, fc, NN, N1_arr, velocity, counter_arr, delay_time, attn, flat)

The following steps are used to explain about variables are used inside the function.. it will not execute while run the code

%****************************** variables *******************************

% idata input Ich data

% qdata input Qch data

% nsamp Number of samples to be simulated

% fs Sampling frequency (Hz)

% fc Carrier Frequency (Hz)

% NN Number of paths

% N1 Number of waves in order to generate fading

% velocity Mobile speed in Km/h

% counter Fading counter

% delay_time Delay for each fading path (ns)

% attn Attenuation level for different fading paths (dB)

% flat flat fading or not

% r Envelope of fading channel complex impulse response

% iout output Ich data

% qout output Qch data

%************************************************************************

v = velocity./3.6; % m/s

c = 3e8;%its light speed 3*10^8

fm = fc*v/c; % Maximum doppler frequency (Hz)

delay_samp = round(delay_time.*fs.*1e-9); % normalized delay time in number of samples

total_attn = sum(10.^(-1.0.*attn./10.0)); % normalize the power

tstp = 1/fs; % minimum time resolution

iout = zeros(1,nsamp);%initalize the iout value

qout = zeros(1,nsamp);%initalize the qout value

r = zeros(1,nsamp);%initalize the r value to zero

theta = zeros(1,nsamp);%initalize the theta value to zero

%Create loop to calculate iout and rout value for all samples which is taken

for i=1:NN

atts = 10.^(-0.05.*attn(i)); % attenuation for current path

  

[itmp, qtmp] = delay(idata, qdata, nsamp, delay_samp(i));

[r_single, iout_single, qout_single] = fade2(itmp, qtmp, nsamp, tstp, fm, N1_arr(i), counter_arr(i), flat);

  

counter_arr = counter_arr+200; % update counter

  

iout = iout + atts.*iout_single./sqrt(total_attn);

qout = qout + atts.*qout_single./sqrt(total_attn);

  

end

r = sqrt(iout.^2+qout.^2);%its formula to find Envelope of fading channel complex impulse response


Related Solutions

Derive the equivalent discrete-time model of a wireless communication system with quasi-static frequency-selective fading.
Derive the equivalent discrete-time model of a wireless communication system with quasi-static frequency-selective fading.
write a matlab function for frequency analysis using DFT. the function should take as input a...
write a matlab function for frequency analysis using DFT. the function should take as input a signal, and as output the number of sinusoids and their frequencies.
The language is MATLAB Write a function that will generate three random integers, each in the...
The language is MATLAB Write a function that will generate three random integers, each in the inclusive range from 10 to 80. It will then return a string consisting of the three integers joined together, and also a character vector consisting of the three integers joined together. For example, if the random integers are 11, 29, and 76, the string that is returned will be "112976" and the character vector that is returned will be '112976'. I'm really confused on...
How to do the following in R: Write a function that will generate and return a...
How to do the following in R: Write a function that will generate and return a random sample of size n from the twoparameter exponential distribution Exp(λ,ν) for arbitrary n, λ, and ν. Note that the pdf of X ∼ Exp(λ,ν) is f(x) = λe−λ(x−ν),x ≥ ν and λ > 0,ν > 0. Generate a random sample of size 1000 from the Exp(2,1) distribution.
Discuss the differences between repetitive and selective statements. Use segment codes to demonstrate your understanding. Explain...
Discuss the differences between repetitive and selective statements. Use segment codes to demonstrate your understanding. Explain why you are choosing one of the following three statements in your code: a) for statement, b) while statement, c) do-while statement. Provide examples.
Write a MATLAB function that will generate chi-square random variables with v degrees of freedom by...
Write a MATLAB function that will generate chi-square random variables with v degrees of freedom by generating v standard normal, squaring them and then adding them up. This uses the fact that is chi-square with v degrees of freedom. Generate some random variables and plot in a histogram. The degrees of freedom should be an input argument set by the user.
In MatLab use the linspace function and the element-wise exponentiation (power) operator to generate the vector...
In MatLab use the linspace function and the element-wise exponentiation (power) operator to generate the vector 1, 10, 100, 1000, 10000 Please give the answer in form of linspace( , , )
Write a matlab code for given task Use your ‘sin’ or ‘cos’ function to generate a...
Write a matlab code for given task Use your ‘sin’ or ‘cos’ function to generate a sinusoid wave having two components as f1 = 3kHz and f2 = 5kHz and then sample it with fs = 10kHz. Calculate its fft with zero frequency component in the middle. Plot it on a properly scaled w-axis. Specify if there is aliasing or not? If there is aliasing specify which component is casing the aliasing
What are the R codes for these questions below: 1. Load the library {car}, which contains...
What are the R codes for these questions below: 1. Load the library {car}, which contains the Salaries data set. #Then, list the first few records with head(Salaries). The display the summmary() for this dataset, which will shows frequencies. Then, load the library {psych} which contains the describe() function and use this function to list the descriptive statistics for the dataset. 2. Load the coefplot library and display a coefficient plot for lm.fit.2 <- lm(salary~sex+yrs.since.phd, data=Salaries) using the coefplot() function....
What are the R codes for these questions below: 1. Load the library {car}, which contains...
What are the R codes for these questions below: 1. Load the library {car}, which contains the Salaries data set. #Then, list the first few records with head(Salaries). The display the summmary() for this dataset, which will shows frequencies. Then, load the library {psych} which contains the describe() function and use this function to list the descriptive statistics for the dataset. 2. Load the coefplot library and display a coefficient plot for lm.fit.2 <- lm(salary~sex+yrs.since.phd, data=Salaries) using the coefplot() function....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT