tag:blogger.com,1999:blog-16304842319077583822017-08-11T08:19:40.932-07:00DSP & Communication Knowledge BaseUbaid Abdullahhttp://www.blogger.com/profile/09369678715275853829noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-1630484231907758382.post-31604524284888380902013-04-20T11:45:00.000-07:002013-04-20T11:45:57.462-07:00What to do if all the MATLAB licenses in your institute are occupied ? <div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Georgia, Times New Roman, serif;">Quite often it happens that when I try to run my MATLAB script that uses a certain toolbox of MATLAB, it gives me the following error:</span><br /><br /><pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> License checkout failed. <br /> License Manager Error -4 <br /> Maximum number of users for Communication_Toolbox reached. <br /> Try again later. <br /> To see a list of current users use the lmstat utility or contact your <br /> License Administrator. <br /> Troubleshoot this issue by visiting: <br /> http://www.mathworks.com/support/lme/R2012a/4 </code></pre><br /><span style="font-family: Georgia, Times New Roman, serif;">This shows that all the licenses for the Communication Toolbox are in use by other people in your company/institution, and you will have to wait until one of them releases the license. It can be a painstaking job to keep executing the same script again and again in the hope of getting the license for yourself. This repeated execution of the script can be automated using the try, catch block.</span><br /><span style="font-family: Georgia, Times New Roman, serif;"><br /></span><span style="font-family: Georgia, Times New Roman, serif;">Suppose, myscript.m is the script you want to run. You can use the following script to keep trying until someone releases a license for you. </span><br /><br /><pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;"> close all;clear all; clc; <br />errcl = 2;<br />while errcl~=1 <br /> try<br /> errcl = 1;<br /> myscript;<br /> catch err<br /> disp('Licenses are still not available ...Retrying after two seconds ...'); <br /> pause(2);<br /> errcl = 2; <br /> end<br />end</code><br /></pre><br />In order to break the loop, press Ctrl+C for a few seconds.<br />You can also change the time between the two tries by changing the argument of <code style="color: black; word-wrap: normal;">pause(2)</code> function from 2 to any number of seconds you desire. </div>Ubaid Abdullahhttp://www.blogger.com/profile/09369678715275853829noreply@blogger.com0tag:blogger.com,1999:blog-1630484231907758382.post-27061335664738682212009-01-05T21:49:00.000-08:002009-01-05T22:04:09.717-08:00Post Your Questions HereThis is the place where you can post your questions and article requests. Please observe the following guidelines while asking questions. In the meanwhile, I will work out some better method to post questions.<br /><br />1. All the code should be embedded in the question if any.<br />2. No code writing requests will be entertained. So please avoid it. The best way is to post your own code and I will try to help you out of your problem.<br />3. If question is related to some already written article, please ask it in the comments section of that particular post. It keeps the information more organized.<br /><br />Best Regards,<br /><br />Ubaid AbdullahUbaid Abdullahhttp://www.blogger.com/profile/09369678715275853829noreply@blogger.com90tag:blogger.com,1999:blog-1630484231907758382.post-48567702863777907542008-11-21T07:02:00.001-08:002009-05-06T05:19:14.524-07:00Simulating Sample Spaced Rayleigh Fading Channel<p>Fading channel modeling is a fairly common step while performing any communication system analysis. This article deals with how to model a fading channel with the assumption that channel taps are sample spaced. The first section tells what are the sample spaced taps of the channel and next the discussion is about how can we model such channel in MATLAB along with an example script. <br />What does it mean by "sampled spaced taps"? Suppose you have the simplest communication system perspective consisting of a transmitter, channel and receiver where the transmitted waveform passes through the channel and is received by the receiver after getting reflected from different obstacles. While modeling we need to discretize the channel so that it can be simulated in MATLAB or any simulation environment i.e. take channel response at particular time instants and not all the time. So a discrete channel is defined by a set of impulses at particular instant of time instead of a continuous response. These impulses at particular instants are called channel taps and every tap corresponds to a seperate reflected wave that comes after some delay. Quite intuitively, there is no binding on the lengths of paths that these reflected waves travel so there is no binding on how delayed these reflected signals will be received. For example, the second wave can come after a span of 1 microseconds of the first wave and the third wave can come after 2.3 microseconds of the second wave. By sample spaced channel taps, we mean that the difference in delays between different waves is either some sampling interval Ts or a multiple of it.</p> <p></p> <p><a href="http://lh4.ggpht.com/_r-TqYqFOuQg/SSbNNqEjM6I/AAAAAAAAABg/iBbpPya3uak/rayleigh_faded_taps_nonuniform9.jpg"><img style="border-width: 0px;" alt="Non Uniform Taps" src="http://lh4.ggpht.com/_r-TqYqFOuQg/SSbNQfhMekI/AAAAAAAAABk/DA-NA3WP568/rayleigh_faded_taps_nonuniform_thumb.jpg" width="240" border="0" height="191" /></a> </p> <p></p> <p><a href="http://lh5.ggpht.com/_r-TqYqFOuQg/SSbNS-3f_kI/AAAAAAAAABo/Od-WNGU02Mg/rayleigh_faded_taps_uniform3.jpg"><img style="border-width: 0px;" alt="Uniform Taps" src="http://lh6.ggpht.com/_r-TqYqFOuQg/SSbNVdkyHQI/AAAAAAAAABs/EEjlpwkmvGE/rayleigh_faded_taps_uniform_thumb1.jpg" width="240" border="0" height="189" /></a> </p> <p>Now, to model the first channel is quite difficult as compared to the second one because the second channel can easily be implemented using a 3-tap FIR filter as the sampling frequency is fixed. </p> <p>So, this is quite apparent that if we want to model such channel using an FIR filter i.e. assuming sample spaced taps, we will have to input the waveform samples (that comes out of the transmitter) with the same sampling interval as that of the time interval between the FIR channel taps. With this assumption, we cannot simulate a channel where taps are not uniformly spaced. For this, we will have to interpolate the input wave and/or the channel response. This will be discussed in the next section of this tutorial. In this article, we consider only the case where channel taps are sample spaced i.e. the time interval (or 1/Sampling Frquency) of the signal is the same as that of channel. <br />All right! We are now ready to simulate the whole process. Lets take an example of modeling the following channel to clarify the whole picture. </p> <h4>Channel Specifications</h4> <ol> <li>No. of Taps = 4 </li> <li>No. of Independent Channel Responses = 2000 </li> <li>Tap Weights and Delays <ol> <li>First Tap = 0 dB with delay of 0 microseconds </li> <li>Second Tap = -5 dB with delay of 5 microseconds </li> <li>Third Tap = -10 dB with delay of 10 microseconds </li> <li>Fourth Tap = -15 dB with delay of 15 microseconds </li> </ol> </li> <li>The sampling frequency of the input signal = 1/5 microseconds = 200 kHz </li> </ol> <p>This channel is sample spaced because,</p> <p>sampling interval of input signal = 5 microseconds = Mx(delay difference between two consecutive taps) where M = 1.</p> <p>The channel is depicted in the following figure.</p> <p><a href="http://lh3.ggpht.com/_r-TqYqFOuQg/SSbNW4tx7SI/AAAAAAAAABw/lJunTuW5XsI/image7.png"><img style="border-width: 0px;" alt="image" src="http://lh3.ggpht.com/_r-TqYqFOuQg/SSbNXxIN3ZI/AAAAAAAAAB0/ZRQn518BudQ/image_thumb3.png" width="240" border="0" height="109" /></a> </p> <p>First we will make 4 independantly rayleigh faded channel taps. This can be easily done by using the fact that the envelope of two gaussian processes with the same variance and mean is rayleigh distributed. One can make a rayleigh faded tap quite easily using following equation and code in MATLAB.</p> <p><a href="http://lh3.ggpht.com/_r-TqYqFOuQg/SSbNZSY_jCI/AAAAAAAAAB4/fGHnM7L6Fj0/image8.png"><img style="border-width: 0px;" alt="image" src="http://lh6.ggpht.com/_r-TqYqFOuQg/SSbNad4aj0I/AAAAAAAAAB8/Yc2ALEKLLh4/image_thumb4.png" width="136" border="0" height="45" /></a> </p> <p><span style="font-family:courier new;">---------------------------------------------------------------</span></p> <p><span style="color: rgb(0, 128, 0);font-family:courier new;">%% MATLAB Code</span></p> <p><span style="font-family:courier new;">no_of_taps = 4; <br />averaging_interval = 2000; <br />tap_weights_db = [0 -5 -10 -15]; <br />tap_delays = [0 5e-6 10e-6 15e-6]; </span></p> <p><span style="font-family:courier new;"><span style="color: rgb(0, 128, 64);">% Conversion of dBs scale into linear one</span> <br />tap_weights_ln = 10.^(tap_weights_db/10); </span></p> <p><span style="font-family:courier new;"><span style="color: rgb(0, 128, 64);">% Calculation of normalization factor to make the average power of output <br />% signal to 1</span> <br />norm_fact = sqrt(sum(tap_weights_ln)); </span></p> <p><span style="font-family:courier new;"><span style="color: rgb(0, 128, 64);">% Generating a Rayleigh Random Variable with average power 1</span> <br />taps = 1/sqrt(2)*(randn(averaging_interval, no_of_taps) + j*randn(averaging_interval,no_of_taps));</span> </p> <p><span style="font-family:courier;"><span style="color: rgb(0, 128, 64);">% Making average power of different taps to specified value</span> <br />taps_weights = taps.*repmat(sqrt(tap_weights_ln), averaging_interval,1); </span></p> <p><span style="font-family:courier;"><span style="color: rgb(0, 128, 64);">% Applying to normalization factor</span> <br />taps_norm = 1/norm_fact*taps_weights;</span> </p> <p><span style="font-family:courier new;"></span></p> <p><span style="font-family:courier new;">---------------------------------------------------------------</span></p> <h4>Normalization Factors</h4> <p>In the above code, there are two normalization factors involved. </p> <table width="401" border="0" cellpadding="0" cellspacing="0"><tbody> <tr> <td width="51" align="center">1.</td> <td width="348"><a href="http://lh6.ggpht.com/_r-TqYqFOuQg/SSbNawC8c0I/AAAAAAAAACA/Z8-bW1a5EVE/image25.png"><img style="border-width: 0px;" alt="image" src="http://lh3.ggpht.com/_r-TqYqFOuQg/SSbNb72RXHI/AAAAAAAAACE/sSGRIQ6oTlM/image_thumb15.png" width="22" align="left" border="0" height="34" /></a> in the assignment of variable "taps"</td> </tr> <tr> <td width="51" align="center">2.</td> <td width="348">norm_fact </td> </tr> </tbody></table> <p>The need for these normalization factors arise due to the following reason. When we talk about different taps, actually different replicas of the signal is being added with different delays. The result is that the output signal from this multipath channel has power more than what was input to the channel. For example, if we have input a signal of power 1, the output of channel shouldn't at least exceed a power of 1. That's why the tap values are scaled so as to make the total output power equal to 1 for an input signal of power 1 while adding all the replicas. Further, every tap is also a summation of two signals in quadrature each with variance (average normalized power in the AC component) equal to 1. In summary, we need normalization at two stages. </p> <ol> <li>To make average normalized power of rayleigh faded process equal to 1. </li> <li>To make average normalized power of all the rayleigh faded taps equal to 1. </li> </ol> <p>In fact, both of these normalization process can be combined as for 2nd normalization we are assuming that each tap has power 1. </p> <p>The very first question now arises what is the power of two normally distributed processes added in quadrature? This can be perceived as follows. The randn command creates a gaussian distributed random variable with zero mean and variance 1. Since, variance represents the average normalized power in the AC (varying) component of the signal, we can say that randn will create a gaussian distributed random variable with 0 DC value and 1 average normalized power in AC component. So, we know that the AC power of the two normally distributed R.Vs added in quadrature is 2 with an amplitude of sqrt(2). To make this signal with amplitude sqrt(2) into a signal of amplitude 1 (that will give in return a power of 1^2 = 1), we need to divide the signal with sqrt(2). That's all about the first normalization factor. It just makes the average normalized power in the AC-component of two normally distributed R.V.s added in quadrature to a value of 1. </p> <p>The same analogy can be applied to the understanding of 2nd scaling factor. We needed first scaling factor because we were adding two signals each of power 1. Now, each tap represents a signal of power 1 and they are being added with different weights (and thus different average powers) to each other to produce the effect of multipath. In our case, the same signal is added 4 times (because of the 4 taps) and the average output power is equal to the sum of average powers of the four taps. As described in the channel specification, the power of different taps is as follows. </p> <ol> <li>First Tap = 0 dB or <strong>1</strong> with delay of 0 microseconds </li> <li>Second Tap = -5 dB or <strong>0.316</strong> with delay of 5 microseconds </li> <li>Third Tap = -10 dB or <strong>0.1</strong> with delay of 10 microseconds </li> <li>Fourth Tap = -15 dB or <strong>0.0316</strong> with delay of 15 microseconds </li> </ol> <p>Thus, the total output power of this channel is 1+0.316+.1+0.0316 = 1.447. If we input a signal of average power 1 to this channel, the average power of the output of the channel would be 1.447. To make the average power of the output signal to 1, we need to divide the taps by sqrt(1.447) = sqrt(sum of linear values of the taps) as done in the code. In summary, both of these normalization factors were incorporated to make the average output power of the channel equal to 1 for a signal of input power 1. </p> <h4>Generating The Taps</h4> <p>Finally, all the taps are generated using these normalizations and two independent gaussian random variables. Following is the code that proves that the average normalized power of different taps is as specified in the channel.</p> <p><span style="font-family:courier new;">---------------------------------------------------------------</span></p> <p><span style="color: rgb(0, 128, 0);font-family:courier new;">%% MATLAB Code</span></p> <p><span style="font-family:courier;">disp('The path gains are as follows (in dB)'); <br />20*log10(mean(abs(taps_norm),1)) <br />disp('The total path gain of the channel is'); <br />sum(mean(abs(taps_norm).^2,1))</span> </p> <p><span style="font-family:courier new;">---------------------------------------------------------------</span></p> <p><span style="font-family:courier new;">The complete MATLAB script can be found <a href="http://sites.google.com/site/dspdotcomm/Home/rayleigh_faded_taps.m?attredirects=0">here</a>.</span></p> <p><span style="font-family:courier new;">The physical meanings of different statistical parameters such as mean, variance etc. are given in chapter-1 of <a href="http://www.amazon.com/gp/product/0130847887?ie=UTF8&tag=dspandcomknob-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0130847887">Digital Communications: Fundamentals and Applications (2nd Edition) (Prentice Hall Communications Engineering and Emerging Technologies Series)</a><img style="border-style: none ! important; margin: 0px;" alt="" src="http://www.assoc-amazon.com/e/ir?t=dspandcomknob-20&l=as2&o=1&a=0130847887" width="1" border="0" height="1" />.</span></p>Ubaid Abdullahhttp://www.blogger.com/profile/09369678715275853829noreply@blogger.com126