## Monday, January 5, 2009

This 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.

1. All the code should be embedded in the question if any.
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.
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.

Best Regards,

Ubaid Abdullah

1. Hi, I have 100 same files to do the same analysis one after another. How can I use one single m.files for analyze same thing for every (total of100) data files easily? Would you please show it step by step.
Thanks for your kind understanding. Zia

2. hello
I want equilazi the rayleigh channel.the cahnnel is as
x=transdata1; % BPSk Data
taps=3;
p1=1;
p2=0;
p3=0;
gain1=sqrt(p1/2)*[randn(1,length(x)) + j*randn(1,length(x))];
gain2=sqrt(p2/2)*[randn(1,length(x)) + j*randn(1,length(x))];
gain3=sqrt(p3/2)*[randn(1,length(x)) + j*randn(1,length(x))];

n=1:length(x);
delay1=1;
delay2=2;
for n=delay1+1:length(x)
x1(n)=x(n-delay1);
end
for n=delay2+1:length(x)
x2(n)=x(n-delay2);
end
transdata=gain1.*x+gain2.*x1+gain2.*x2;

noise = 1/sqrt(2)*[randn(1,length(x)) + j*randn(1,length(x))]; % Noise
snr = [0:10]; % multiple Eb/N0 values
ps=mean(abs(x).^2); % Power of the transmitted signal
for i = 1:length(snr)
y = transdata + (sqrt(3*ps)*10^(-snr(i)/20))*noise; %Addition of Noise
Initially I am using only one Tap and after going to increase.
how I equalize the channle at receiver.
Abrar

3. @zia
You can do it the following way.
1. name the files in some alphanumeric way that is deterministic. For example, name your files as 1.txt 2.txt and up to 100.txt
2. Now make a function in which you takes the data of the file as input and process it.
3. make a wrapper file. in this wrapper file, do the following

for cnt = 1:100,
fid_in = fopen(num2str(cnt),'r');
fid_out = fopen(['o' num2str(cnt)],'r');
data_in = fscanf(fid_in,'%d');
%% Process the Data Here by calling your function
fprintf(fid_out,'%d', results);
fclose('all');
end

Besides, if your processing is too exhaustive, you shouldn't use MATLAB for such batch processing. Convert your code to a C++ one, and repeat the same alogrithm. MATLAB goes slow as the processing time increases due to its memory management inefficiency.

Ubaid Abdullah
http://dpsdotcomm.blogspot.com

>>Zia said...
>>
>> Hi, I have 100 same files to do the same analysis one after another. How can I use one single m.files for analyze same thing for every (total of100) data files easily? Would you please show it step by step.
>> Thanks for your kind understanding. Zia

4. hi what of eqaulizer should i use for ofdm.can you show me how to code it in matlab please

5. Salam and hello every one
i am new here:
i want to design LPF,BPF..
it is my lab assignment can any one guide me how i should start this.

regards

6. @Anonymous
you can use LS (least square) or MMSE (minimum mean square error) based equalization. for example you have the channel estimate h(k) for kth subcarrier. the LS equalization would be as follows

out_symbol(k) = in_symbol(k)./h(k)

for mmse based equalization, you will take into account the SNR of the sub-carrier as well. i.e.

out_symbol(k) = in_symbol(k)./(h(k) + SNR^-1)

the inclusion of SNR in this case has the advantage that it avoids the noise enhancement problem in the system. for more information and details, go for the equalization chapter in the following book.

Wireless communications by Andrea Goldsmith.

7. @naveed ahmed
if thats a lab assignment dude, i would better urge you to do it yourself :) in case you try and dont get things straight post your code here i would guide you. to start with you should try MATLAB help. type fdatool in the MATLAB command window and brush up yourself with basic requirements that filter design needs. for theoretical details, read the following.
Chapter-7 FIR Filter Design
Digital Signal Processing - A Practical Approach 2nd Edition by Emmanuel C. lfeachor and Barrie W. Jervis.

regards

8. i need matlab code general for the flow routing...tq

9. @Anonymous
"matlab code general" thats really abstruse:) Elaborate a little more what your problem is and what you have done so far so that i may help you.

10. Hi Asalamualaikum ..my name is amri from Malaysia. Currently i am postgraduate student at Kuala Lumpur. My project is flow routing., queueing or Markov chain. I need ur help to do the programming in Matlab. I am very weak in program could u help me....
1. What is the book or article i need to read regarding this topic especially in eraly flow discard..
2. how i can to simulate that in matlab...including equation math
tq
best regard

11. well amri flow routing is as i suspect a network layer issue. I am not at the top of network layer and can guide you in physical layer design only. so i dont know which book or article is appropriate.
as far as MATLAB programming is concerned, i dont think it is a good idea to use MATLAB for the simulation of network layer algorithms. a better tool is Network Simulator NS-2. you can google about it to get more information. Still, if you specifically post your problem i would be able to help you in a better way.

12. hai....
i'm zaki from east java indonesia

i have any question :
1. i want request data for matlab code for
signaling proses at wimax
3. all request i create with MATLAB

13. @zaki
i really have no idea what you want to do. i would be more helpful if you write it a bit clearly. If you have written any code and facing some problem in it, you can post the chunk here and i will go through it.

14. good day Ubaid Abdullah,

Currently I'm involve a project regarding digital predistorter and implementation in DSP. i'm using the eZdspVC33 DSP. The programming code for predistorter was written in MATLAB. I've to run the digital predistorter using DSP. I've two major questions.

First:
Can I send the predistorter code to dsp using matlab and run it using matlab? if can, i should use simulink or i have to write another code to load the predistorter code and send to dsp?

Second:
I've the Code Composer 4.0. Can I write mablab code in code composer? If i use C programming, can you guide me, how to import the matlab predistorter code using C programming?

15. @k.e.lam

@@first
yes you can do that using Simulink's Real Time Workshop Embedded Coder with Target for C2000/C6000 (based on the development board you are using).

@@second
No you cannot write Matlab code in Code Composer studio. Instead, use the method described in @@first.

If you have installed Matlab, go to the Full Product Family Help. And, there search for the above mentioned Real Time Workshop Embedded Coder and Target for C2000/C6000. It will give you a primer on these tasks.

16. (From the email)
Hi salaams,
Well in that site i didn't find any option to upload code, so i m sending u here.
"Ba" is folder for code, its applied on just 1 image "whale". Its working fine with that. I wanna apply it on attached two images "trees.gif" and "pepsi0.gif". Its giving error with those images. In paper this coding is applied on these 2 images.
So plz tell me where do i hav to make changes
Hope to hear from u soon
Best regards
Mehwish

http://www.cs.brown.edu/~dqsun/research/software.html

17. @Mehwish
This code estimates the optical flow in a sequence of frames. You need to place these frames in the data\other-data data\other-data-gray and name it a sequence greater than 8. Now call this function in MATLAB command window with the appropriate sequence number, it will work. As far as the two files are concerned, in my opinion you cannot run this code for those two files you sent me because they are not sequence of the same video or motion. You need at least 2 images for simulation in a sequence for example the pepsi image and another image with the bottle slightly displaced. See the images in data\other-data folder as their is a slight flow of objects.
Besides, it is always better you contact the author of this code and he may explain it to you in a better way.

18. Good day,
I've a problem in linking the program and need your help. I am using TI TMS320C31 board. I wrote a program in C. I compiled the program and it shows not error. However, when I link the program into .cmd, it shows error.

These are the errors:
>>cannot allocate .text in RAM0 < page 0 >
>>can't allocate .bss, size 000005d3 < page 0>
>>can't allocate .const, size 00000309 < page 0>
>>can't allocate .sysmem,size 00000400 < page 0>
>>errors in input - dspfinal.out not built

I was using the command "lnk30 dspfinal.cmd". Below is my dspfinal.cmd file.

-c /*using C convention */
-stack 0x100 /*256 words stack */
matrixc.obj /*object file */
-O matrixc.out /*executable output file */
-l rts30.lib /*run-time library support*/
MEMORY
{
RAMS: org=0x809800, len=0x2 /*boot stack */
RAM0: org=0x809802, len=0x3FE /*internal block 0*/
RAM1: org=0x809C00, len=0x3C0 /*internal block 1*/
}
SECTIONS
{
.text: {} > RAM0 /*code */
.cinit: {} > RAM0 /*initialization tables*/
.stack: {} > RAM1 /*system stack */
}

19. @ Ubaid Abdullah
Thank u so much for ur prompt reply
i asked author for help, he sent me those images ( pepsi and trees) didn't send its frame. Now i thought to extract frmaes myself from some movie but i m unable to get frames from getframe function.
Anyhow thanks
Best regards
Mehwish

20. @Mehwish
why dont you use the print screen key on your keyboard and paste it in paint brush :) sometimes things are lot easier without MATLAB.

21. @ Ubaid Abdullah
I guess that'll not work, as i'll not be able to get Consecutive frames. Anyhow i got VLC software for that purpose.
Thanks

22. @Mehwish
you can pause the video for a particular frame and then capture the screen. After that repeat the same procedure after playing the video for a second.

23. @ Ubaid Abdullah
well
infact i need those frames in .png format. And VLC gav me easy way to extract frmaes in required format.

24. I need to design a multiplierless filter having coefficients h=[1 -1 -1 -1] which is neither symmetrical or antisymmetrical.
What is the trigometric function in frequency domain?

25. I need to design a multiplierless filter having coefficients h=[1 -1 -1 -1] which is neither symmetrical or antisymmetrical.
What is the trigometric function in frequency domain?

26. @anonymous
@@multiplierless filter
multiplication with 1 means nothing in hardware and multiplication with -1 means a 2's complement (supposing you are using 2's complement arithmetic). So, there is no multiplier involved at all in this structure and you can design it with a simple delay line, 3 2's complementer and one adder. I hope I understood your question right.

@@Trigonometric Function in frequency domain?
I really dont understand this sentence. Elaborate a little more ...

27. For example

if H(z) = 1+z^-1
then abs(H(e^-jw)) = 2cos0.5w

and therefore how do I represent
H(z) = 1-z^-1 -z^-2 -z^-3 in the trignometric function.

Regards

Supramaniam

28. For example

if H(z) = 1+z^-1
then abs(H(e^-jw)) = 2cos0.5w

and therefore how do I represent
H(z) = 1-z^-1 -z^-2 -z^-3 in the trignometric function.

Regards

Supramaniam

29. For example

if H(z) = 1+z^-1
then abs(H(e^-jw)) = 2cos0.5w

and therefore how do I represent
H(z) = 1-z^-1 -z^-2 -z^-3 in the trignometric function.

30. Salam,
I would like to know if u have any idea how i can build rayleigh channel with AWGN and OFDM,QPSK modulation
Munzir Abubaker

31. @Munzir
You can build rayleigh channel with the same code as I provided with this article. If you have MATLABs communication toolbox, you can use rayleighchan command for this purpose too. To add awgn, just generate the noise of your desired power using MATLAB's function randn and add it to the channel filter output. Alternatively, you can use the Communication Toolbox function awgn as well for this purpose. As far as OFDM/QPSK simulation is concerned, you need to study in detail for these topics as they cannot be dealt in a small answer. Read some text about it and ask specific questions when you feel difficulty in understanding any concept.

32. For example

if H(z) = 1+z^-1
then abs(H(e^-jw)) = 2cos0.5w

and therefore how do I represent
H(z) = 1-z^-1 -z^-2 -z^-3 in the trignometric function.

Regards

Supramaniam

33. For example

if H(z) = 1+z^-1
then abs(H(e^-jw)) = 2cos0.5w

and therefore how do I represent
H(z) = 1-z^-1 -z^-2 -z^-3 in the trignometric function.

Regards

Supramaniam

34. @supramaniam
please post a question only once.

You can evaluate the H(z) at z = exp(jwT) to give you the trigonometric function corresponding to this particular H(z).

35. I have used your approach but not able to represent as a real trignometric function.I have got an imajinary value within the answer.

ie H(e^jw)=2*sin0.5*w -e^-2jw*2Cos0.5*w

Is this representation correct?

Regards

Supramaniam

36. @Supramaniam

If you need the magnitude plot, use
abs(H(ejw)) = sqrt(real.^2+imaginary.^2)

I have problem and I can't figure it out although it seems simple and basic thing. It is regarding mean square error (MSE).

I attached titled "A simple preamble for OFDM timing offset estimation".

It is very short paper.

It has 3 figures.

figure#2 is the mean error, and figure#3 is the MSE. if you look into figure#2 for the proposed method the values roughly "1.2,-0.1, -0.1, -0.1,-0.1".

However the values for the MSE for the same method is "10^-2, 1x10^0, 10^-2, 8x10^-3, 7x10^-3, 6x10^-3"

My question How come when SNR=0 dB for example, the mean is 1.2 and the MSE is 10^2!

In my simulation I have vector of errors in matlab of 100 elements. Its mean is 1.8, and MSE=11.8.

What I understood is MSE=mean(errors.^2).

Is there any other formulas of MSE like normalized MSE or so?

Please take a look at the uploaded file and look to figures#2, and 3 and tell me what you think. I know it very basic question but I want to understand what is going on. Thanks in advance.

Regards,
Khalid,

38. @Khalid Almuzaini
From your post, I think you want to ask the following question.
"MSE is quite large whereas the corresponding Mean is very low. Is this possible?"
Yes of course. MSE is dependent on the variance of the quantity and mean has no direct relationship with MSE. For example, consider the following MATLAB code.

rand_var = 100*randn(1,10000) + 1.2;
mean(rand_var)
mean(rand_var.^2)

MSE is quite large whereas the mean is same 1.2.

Ubaid

39. Now I got it. Thanks ubiad. I am still try to correctly implement the OFDM system in the paper which I sent to you since 10 weeks or more and still I can not get the same MSE curve!! I will keep trying and if you have any hint or certain procedure for implementation please let me know and I will really appreciate that. Thanks again.

As I told you before I have trouble in generating the same MSE curve for timing offset in OFDM system.
I tried to generate the MSE curve in the paper that I sent to you before. I am attaching it here again just in case.
Also, you find my matlab code at the end of this email.
Can you please check it for me and tell me what I am doing wrong because this is driving me crazy since more than 10 weeks!!!!
every thing seems clear and simple but I can not get the same results as others. There are few other papers the generate the same MSE curve.
I am talking about MSE curve for Park who is the author of the attached paper.
I am really appreciate all your efforts and time to help me and others too.

Regards,
Khalid;

MATLAB code is:

Nu=64; %number of points of IFFT
no_of_taps=4; % number of multipath
spacing=2; % spacing between multipaths
Z=Nu/8; % the is just a delay before OFDM symbol arriving

ts=1; %Sampling time
tau=0:1:no_of_taps-1;
tau=tau*spacing; % arrival time of multipaths
pdb=linspace(0,-24,no_of_taps); % gains of each multipath
ch1 = rayleighchan(ts,0,tau,pdb); % generating Rayleigh channel using built-in function of matlab.

general1=randsrc(Z,1);
general2=ifft(general1); % random OFDM symbol representing data.

park1=randsrc(Nu/2,1);
park2=upsample(park1,2);
park3=ifft(park2); % designed OFDM preamble according to the paper which I have sent to you.
park4=[zeros(Z,1);park3;general2]; % forming general arriving scenario, i.e. no activity in the beginning of length Z then OFDM start appearing following by data OFDM symbol.

SNR=0:4:20;
for p1=1:length(SNR)
for p2=1:1e2
park5=filter(ch1,park4);
Ppark=awgn(park5,SNR(p1),'measured');
L=Nu/2;
for d=1:size(Ppark,1)
P=sum(flipud(Ppark(d:d+L)).*Ppark(d+L:d+L+L));
R=sum((abs(Ppark(d+L:d+L+L))).^2);
Mpark(d)=(abs(P^2))/R^2;clear P R;
if d+L+L==size(Ppark,1), break;end
end
[p_park,i_park]=max(Mpark);
e_park(p2)=delay-i_park;
clear Ppark i_park
end

meanPARK(p1)=mean(e_park);
msePARK(p1)=mse(e_park);
clear Ppark
end

figure(1);semilogy(SNR,msePARK,'k');

41. Hi ubaid. I missed one line which defines delay.

delay=Z+1;

42. Hi Ubaid Abdullah,

I am Remy, a student. I would like to use MATLAB Data Acquistion Toolbox to acquire the analog input signal (heart beat) from a sensor to my PC. WindowXP can support the following adapters:winsound, advantech,mcc and nidaq.Unfortunately, the only adapter that is integrated in my PC is the soundcard. Thus,what adapter do I need to use for my application?

Thank you a lot in advance.

Remy Twiringiyimana

43. Hi Ubaid Abdullah,

I am Remy, a student. I would like to use MATLAB Data Acquistion Toolbox to acquire the analog input signal (heart beat) from a sensor to my PC. WindowXP can support the following adapters:winsound, advantech,mcc and nidaq.Unfortunately, the only adapter that is integrated in my PC is the soundcard. Thus,what adapter do I need to use for my application?

Thank you a lot in advance.

Remy Twiringiyimana

44. @Remy
Definitely, you will use the PC sound card for this purpose. If you are asking which parameter you should pass in the analog, use the following
Or alternatively, you can use softscope for testing purposes. To launch softscope without any data capture hardware specified, write the following in MATLAB command line.

softscope

if you have only sound card installed, it will show you the winsound option in adapter drop down menu. Hope that helps.

45. Dear Ubaid Abdullah,

Now my question is the following:
Can the sound card be able to acquire electrical signal of about 3V? If so, then I need to attach the sensor terminals (signal and ground cables)to the pc input cable immediately without any other adapter?

Remy

46. You have to read the data sheet of your sound card for this. Typically it is in the range of 1.6 Vrms etc. So better be careful!

47. Dear Ubaid Abdullah,

Thank you very much for your help.

Kind regards.

Remy

48. Sir Ubaid Abdullah
My name is Shanar, I’m working on wimax PHy layer, I want to change the channel between the transmitter and the receiver form (AWGN) to (SUI 3 ) using matlab2008 simuling. I have the value of each taps put I can't use it, I stuck with this problem for 10 weeks, I'm asking your aid, Could you please show me the way out.

49. Dear Ubaid Abdullah,

I am doing the experiment on how I can get a sinewave signal from function generator and acquire the signal and count how many pulses are acquired in 60 seconds using Matlab.

So far, I wrote a matlab code that can acquire the sinewave, but I am stuck with how I can count the pulses in 10 seconds.Can you help me?

The following is the Matlab code for sinewave signal acquisition.

Remy
%% this matlab code is meant to acquire a sinewave signal from the
%%% function generator, count the number of pulses in that sinewave in
%%% 60 seconds using Matl________________________
%________________________________________________

%%%%%%%%%%%CREATE THE OBJECT%%%%%%%%%%%%

%%%%%%%%CONFIGURE PROPERTY VALUES%%%%%%%%%

duration = 60; %60 seconds acquisition
set(ai, 'SampleRate', 9000);%Specify the per-channel rate at which analog data is converted to digital data

ActualRate = get(ai,'SampleRate');% define the device sample rate. This might be different fro the specified value
set(ai, 'SamplesPerTrigger', duration*ActualRate);%Specify the number of samples to acquire for each
%channel group member for each trigger that occurs.
set(ai, 'TriggerType', 'namual'); % set the manual trigger function.
%The trigger will occur immediatly after the trigger function is manually issued
blocksize=get(ai,'SamplesPerTrigger');
Fs=ActualRate % define the sampling frequency

%%%%%% DATA ACQUISITION %%%%%%%%%%%%%%%%%%

start(ai);
%trigger(ai);% apply a manual trigger
wait (ai, duration+1)%pause MATLAB until either the acquisition completes or the timeout elapses
%Adding 1 second to the duration allows some margin for the timeout
[data,time] = getdata(ai); %extract all data from the engine
size(data)

input('press any key to visualize the acquired data')

figure(1)
plot(time,data);
grid on;
zoom on;
title('Acquisition of the signwave signal by manual Triggering');
xlabel('Relative time in seconds.');
ylabel('Data in volts');

%%%%%%%DATA ANALYSIS%%%%%%%%%%%%%

input('press any key to visualize the Power Spectral Density of the aquired data')

figure(2)
psd(data)

50. Angelo SebastianelliJuly 16, 2009 at 3:38 AM

Dear Ubaid Abdullah,
i am angelo and i am student doing his master thesis on ofdm synch.

I am trying to simulate the rayleigh channel but i am quite confuse
about which parameters should i use.

Could you help me somehow?at least with some good references.

Sorry if i am writing you here but with the code the message was more
then 4000 characters.

regards

Angelo

51. Dear Ubaid Abdullah,

Can you help me to knwo hwo I can acquire analogue data by mathlab through "line in" instead of microphone of the computer?

Kind regards.

Remy

52. Hello Ubaid,

I know that you're very busy so you didn't find a time to check my code yet. Anyway, I have few gerneal questions in OFDM matlab implementation:

1- The output of the IFFT at the TX side are complex. should I make them real before sending them? I mean by adding conjugate symmetric values to the data symbols before applying IFFT?!
2- How I can add the timing error to my OFDM system so I can estimate it? Is it just adding zero samples before the OFDM symbols?

53. HI,IT IS ACTUALLY A PLEASURE TO READ FROM THIS SITE.I am a student teacher and i want to use Matlab to build an interphase which can be used to teach polynomials ( mathematics) in secoundary school.I want you to help me please.Tell me what to do.my e-mail address is dimray2k@yahoo.co.uk.
I am seriously waiting.Thanks

54. Dear Ubaid Abdullah,

Can you help me to know how I can acquire frequency of audio input from microphone?

55. I never implemented one but I will try to help you as much as i can.
It depends on what your conditions are i.e. how much noise, how many tones, how far apart they are, how much accuracy you can trade off for speed. Zero crossing detector is a fairly common method of doing so (intuitive too) along with prefiltering. You can also take FFT of the input signal and look for the bin that has maximum value. Google for DTMF detection. I hope you will find a lot of material on it and you can always tweak them to suit your conditions.

one person speak with microphone,i want to split each word of speech in a wave file(real time)and save it and continue recording.low noise.accuracy is important.
how can i know end of each word?

57. Well I am not the right person to ask any question on speech recognition so have no idea how to know 'the end of each word'. I might be helpful if you know the algorithm and face problems in implementing it in Matlab. Good Luck!

58. Dear Ubaid Abdullah,

i'm done writing my code which is to get a spectra for fiber bragg grating(a bell shape graph). in the code itself contains a lots of parameter. the problem is how do i optimize each of the parameter using nelder-mead simplex algorithm. i do hv the codes (nelder-mead simplex) but i dont really know how to integrate both codes.

59. hi,I am a new master student, I am working on uwb channel estimation for bpsk input signal. I kind of figured out the multi-path channel model and the bpsk signal, separately. now I want to pass the signal through the channel, should I use filter comment from matlab library,and if yes how to implement it,thanks sooo much for ur help

60. @anonymous
Let's say you have the signal 'sig' and you want it to pass through a channel with taps 'chan' you should use

chan_out = filter(chan, 1, sig);

For example,
chan = [1 0.3 -0.1];
sig = 2*randint(1,100)-1;
chan_out = filter(chan, 1, sig);

61. thanks a lot for your help, really appreciataed,

I am trying to regenerate the result of the paper below:
Ultra-Wideband Compressed Sensing: Channel Estimation
Jose L. Paredes, Member, IEEE, Gonzalo R. Arce, Fellow, IEEE, and Zhongmin Wang
I have the modulated BPSK signal(containing 5 gaussian monocycle y=A*(t/pw).*exp(-(t/pw).^2);)

->pass the signal through multipath channel IEEE 802.15a ChannelModel based on the Saleh Valenzuela model
(in Residential enviroment, line of sight,sampled with peterson_sampling ) ->
-> recover the received UWB signal Using Time Sparsity Model(250 and 500 random projections) and Multipath Diversity(250 random projections)
->detection based on compressd sensing (CS): CS correlator-based detector and CS Rake-based detectors
->simulation to get: BER Performance for (line of sight),(Non light of sight), Different Number of Pilot Symbols, and Different Number of Projections

1-either I could add the gaussian noise before the channel:
noise=(1e-50)*(randn(size(t)));
noisy_sig=modulated sig +noise
or
noise = randn(1,length(modulated sig))
Chan_Noise = noise * sqrt(noise_var);
noisy_sig = [noisy_sig ; yp+ Chan_Noise];
which one is better?

2-where should I apply the sensing and measurement matrices (Psi and Phi)?
in order to recover the signal in the receiver side using matching pursuit for compress sensing

3- in the channel model, if i am given time of channel rays , t_ray= [0,0.12,0.22,0.37,0.5,0.81]' , the way to find sampling frequency 'fs'
is finding the smallest time difference btw elements of 't_ray' that is 'ts' and ts=1/fs ?
is 'ts' called time resolution (the bin duration, sampling time, sampling period)?
thanks so much

62. hi, me again
4-I need to plot the channel 'h' that is the multipath channel,'h' versus 'time'
I tried plot(time,h), but matlab gives me error:'Vectors must be the same lengths'
When I use the command 'size(h)' in each run gives me different length of 'h' (bcs of the Randn)
so how can I find the right 'time', I also tried the commands:
plot(t_ray,h_ray)
stem(t_ray,h_ray)
plot(1:1/fs:ts_max,h)

There is also the following code, but I cannot figure out 'time' ,
in my code ts_max = ceil(max(t_ray)/ts); is my 'ts_max' same as 'Tmax' in the code below?

Graphical Output
% % -----------------------------
% Tmax = dt*length(h0); %maximum time ,( dt is either decay thereshold or 1/fs, not sure?)
% time = (0:dt:Tmax-dt);
% figure(1)
% S1=stem(time,h0); %channel impulse response h0
% title('Channel Impulse Response');
% xlabel('Time [s]');
% ylabel('Amplitude Gain');
% figure(2)
% S2=stairs(time,hf); % equivalent discrete-time impulse response 'hf
% title('Discrete Time Impulse Response');
% xlabel('Time [s]');
% ylabel('Amplitude Gain');

Thanks many times
MW

63. 5- Is this order correct:
modulated signal->sensing modulated signal -> channel-> received noisy signal->reconstruct modulated signal using Matching Pursuit
Where do Correlator-based and Rake-based go ?

64. @anonymous/mw
1. you should add the noise after passing it through the channel so that received SNR can be established. remember that after passing through the channel the power of the signal will not be same so you should take this into account while calculating snr.

2. I never studied anything related to compressed sensing so of no help here.

3. I don't know if you are asking that can we call it time resolution or is it usually called time resolution. While calculating sampling period/time resolution you should also note the sampling period of the incoming signal. For example, you can find the smallest difference between elements of t_ray but if your incoming signal's sampling period is less than this t_ray value, the sampling period of the whole simulation will be dictated by the incoming signal and not by the channel. In summary, the sampling period of incoming signal and period at which channel is sampled should be same.

4. You are getting this error because your vectors t_ray and h_ray are not of the same length. If you are trying to plot a power delay profile, you should plot using
plot(t_ray, h_ray);
I don't know why the length of channel vector h_ray changes because if you have a six tap channel, the length of h_ray should always be 6. What changes from one realization to the other are just the magnitudes of these taps and not the number.

5. I don't understand your question in general and sensing modulated signal, matching pursuit and the last line in particular. If this is something related to compressed sensing, I may not be of much help here.

65. Hi there brother,I can see you are doing a great job here by offering good solution, anyway currently im modelling a wireless communication for QPSK and BPSK.Im using Rayleigh channel.

I am not working in RF wireless network,but Im learning it to compare it with my optical network.

The formula for Rayleigh channel that im using is

Rayleigh=(1/sqrt(2))*(bits)+(1/sqrt(2))*j*(bits)

Then take the magnitude of the formula above and convolute with my modulated signal. I take the rayleigh channel in terms of complex value interference. I am sorry if it looks very elementary.

So now how can I include a certain distance in the channel, say im transmitting from a central station with a BPSK signal, then it goes through this Rayleigh channel and get faded, and then receive at base station. But how to define the distance it travelled.

Below is my matlab code.

close all
clear all
clc
No_symbols=1e4; %Number of symbols (m=log2M,==>m=log2(4)==>m=2)
M=2; %number of binary codes
m=log2(M); %number of bits per symbol
SNR_dB=0:1:14; %defining Signal to Noise Ratio (in Decibel)
SNR=10.^(SNR_dB./10); %Signal to Noise Ratio in linear form.(element by element 10 to the power of (SNR_dB./10).
SER=zeros(1,length(SNR_dB)); %Symbol error rate

for k=1:length(SNR);
error(k)=0;
for i=1:200

x_input = randint(1,No_symbols,M);

Tx_signal=pskmod(x_input,M);

Tx_signalCom=Tx_signal.*(1+j);

ak1=(1/sqrt(2))*randn(1,No_symbols)+(1/sqrt(2))*j*(randn(1,No_symbols));%Generating complex fading channel(as complex Gaussian random)
ak_abs=abs(ak1);
Tx=(Tx_signalCom.*ak_abs);
G_aw=(1/sqrt(2*SNR(k)).*(randn(1,No_symbols).*(1+j)));
Rx_signal=Tx+G_aw;
De_mod=pskdemod(Rx_signal,M);

66. The attenuation in the signal due to distance is usually referred to as Path Loss in literature. Just google path loss and you will find detailed information. For a more rigorous model, you can include log normal shadowing as well (if it is justified in your channel conditions) and then superimpose the rayleigh fading on this log normally shadowed signal. So in summary, you should google the following terms and you will get what you need.
1. free space path loss
Hope that helps.

67. hi brother, thank you for the feedback, I got the free space path loss formula, thank you very much, it actually defines the distance in that formula, im looking into shadowing as well.

Anyway, may i ask you what is exactly mean and variance does for the random interference modelling of Rayleigh. I understand that mean must be 0 and variance must be 0.5 for Rayleigh. But how it helps and how to actually identify it from this formula:

ak1=(1/sqrt(2))*randn(1,No_symbols)+(1/sqrt(2))*j*(randn(1,No_symbols));%Generating complex fading channel(as complex Gaussian random)

Im when through reference and some studies on this, but i dont get the meaning. Please advice on this.

68. variance of any r.v. is the power in ac component and mean is actually the dc level of the signal. so variance in your case shows what average ac power you want your channel taps have. They will be dictated by your channel conditions and will be included in the channel specifications you are simulating. For example, if there is a channel with power delay profile as follows,
1st tap -> 0 dB Rayleigh
2nd tap -> -3 dB Rayleigh

then it shows that the variance of first tap is 1 while the variance of second tap is 0.5.

69. Hi brother, how are you? I have a question here. In order to generate a type of noise, say thermal noise of a photodetector.

Can I generate a gaussian random variables, and multiply or convolute them with the thermal noise variance which in this case is

Pth=4*k*T*Be.

Can i do this, is this way correct? Cause I make the gaussian random variable as the PDF of this noise. Thank you.

70. hello , Furqan From Pk
can you plz sovle the following questions

1. A DSP System is preceded by a sample and hold with an aperture time of 10ns and acquisition time of 1 micro second followed by an 8-bit bit ADC. Determine the maximum ADC conversion time to support time support a sampling frequency of 100KHz.

2.Apply the correlation theorem to calculate the linear correlation of the data sequences {1,1,0,and,1} and {1,0,0,1}. Plot the correlation function against lag numbers.

71. hello ubaid ,
> Excellent expalanations .
> i am trying to simulate a power delay profile for a rayleigh channel and plot it against the SNR values in an OFDM system. what methodology should i adopt ? the channel is being generated by the formula

tau=[0.5 3.2 4.5]; %The fractionally spaced taps.. should i take integer values ????
P= [1 0.8 0.5 ]; %% Power profile.
L = length(tau);
for k=1:256
s=0;
for m=1:3
s=s+ P(m)*(exp(-j*pi*(1/256)*(k+255*tau(m))) * (( sin(pi*tau(m)) / sin(pi*(1/256)*(tau(m)-k)))));
%This formula is from a IEEE paper on channel estimation by jaan jaap vaan de beep
end
g(k)=s/sqrt(256);
end

G=g'; %Thus, the channel vector is evaluated..
> am i going on the right lines ?? i wish to plot power delay profile against SNR values in an OFDM system . i am working on channel estimation techniques in OFDM .

72. I'm working on a project, Channel Estimation in OFDM Systems. I have a bit poor knowledge in Digital communication and Probability theory. I have come for your help through mail as I want to be more clear to you about my problem.

My project deals:
Channel Modelling with Complex Exponential- Basis Expansion Model (CE-BEM)
Kalman Filter based channel estimation
I'm facing problem at the first step itself. I need to model the channel as CE-BEM. Th equation for the channel tap matrix at every instant of time is given by

h(n,l)=[summation(q=-Q/2 to Q/2)] (c(l,q)*e^(jwqn))

where, c(l,q) is BEM coefficients assumed to be iid zero mean complex gaussian random variables
number of channel taps L=4; l=0:1:L-1
n=number of time instants 0<n<M(N+gi)
Q=4; q=-2:1:2;
wq=2pi(q)/(G(N+gi))
G-gaurd interval=10
N=number of subcarriers=128
gi=cyclic prefix=8

My code for the above is:

N=128;%subcarriers
gi=8;%cylcic prefix length
G=10;%guard interval
q=-2:1:2;%q=-Q/2:1:Q/2, where Q=4
wq=(2*pi*q)/(G*(N+gi));
varw=1;

c1 = (wgn(1,5,0,'complex'));%first path gaussian random variables c(1,q)
c2 = (wgn(1,5,0,'complex')); %second path gaussian random variables c(2,q)
c3 = (wgn(1,5,0,'complex')); %third path gaussian random variables c(3,q)
c4 = (wgn(1,5,0,'complex')); %fourth path gaussian random variables c(4,q)

c=[c1; c2; c3; c4]; %c(l,q) which is a 4*5 matrix 4channel taps which 5 BEM Coefficients for each tap

n=1:1:5;
e=exp(j*wq'*n);
h=corr(c',e);
h2=h'; %BEM Channel matrix
H=[h2(:,1);h2(:,2);h2(:,3);h2(:,4)]; %reshaping it as a vector for passing through it rayleigh fading channel
c1 = rayleighchan((6.4690e-013),(2.5764e+10));
c1.StoreHistory = 1;
y=filter(c1,H)

In this code code, I have used single path rayleigh fading channel. But I need to use multipath one. For using it I'm in a confusion, what values to be given for average path gains and path delays.
I have referred communication tool box, where I found the usage of DOPPLER FILTER. which one should I use and where shall i use? And also, please verify my code and suggest me the corrections.

Thanking You.

Regards,

First of all, I don't know about the BEM channel so confirm whatever I am saying with someone else as well.
To me it appears that the h(n,l) is the channel realization at time l where n stands for the taps. When using rayleigchan command, it assumes that the channel taps at different time l1, l2, l3, ... are distributed with rayleigh pdf. In your specification I don't see any specification for the distribution of taps? So, I am concerned why are you using rayleighchan command?
Secondly, given you know the channel tap matrix h(n,l), you can create different channels by just filtering your signal through the columns of this matrix e.g. h(n,1) is the channel at time l=1, and so on. I don't see a need for rayleighchan command?
Thirdly, if your symbol rate doesn't match the time instants l, I think (I am not sure) you can interpolate the channel response at any time instant in between l1 and l2?
For time reasons, I am sorry I cannot debug your code. I will be helpful to you if you can specify your problem in a line or two ..

74. This mail is with reference to this blog.
http://www.dsprelated.com/groups/matlab/show/6745.php

Sir I am working on SUI channels and I also have same questions. I am unable to understand your answer on this blog.

This code doesn't use the time delays of different channel taps. Only
the instantaneous values of these taps is given at the times dictated
by observation rate. If you want to use this channel for your sampling
frequency/symbol rate you will have to interpolate/decimate the 3 -
tap values. Note this resampling is not the one that is done in the
end of the code. That resampling is for different channel
realizations. In a single channel realization (that is defined by
3-tap values at specified instants), you need to interpolate/decimate
according to your signal sampling frequency.
Please explain your answer in detail. how can i use this channel with the transmitted data? Do I need to convolve/filter the data with re-sampled channel coefficients according to the rate of transmitted signal? or I should create only one realization of channel, and use the resulting 3 taps and convolve my data with them?

Thanking you in anticipation.

1. Let $$x_i[n]$$ be your BPSK modulated data and $$h_i[n]$$ be the channel impulse response for frame $$i$$ then your received signal $$y_i[n]$$ is given by
$y_i[n] = h_i[n] \star x_i[n] + w_i[n]$

where $$w_i[n] \sim N(0, \sigma^2)$$.
In that blog, OP asked the question why the tap delays are not used? For example, the channel delay profile says that first channel is at 0 dB (0 \mu sec), the next tap is at -5db ( $$1 \mu sec$$) and the third tap is at -10db($$3 \mu sec$$). As you can see in this profile, the three taps are not equally spaced in terms of time. Thus, if our input data is sampled at $$f = 1 MHz$$, $$h_i[n]$$ is given by

$$h_i[n] = [0 -5 0 -10]$$.

Note that the third tap in above example is zero because at this sampling rate the profile explicitly states that there are only three taps.
Now assume that the delay profile says that first channel is at 0 dB (0 \mu sec), the next tap is at -5db ( $$.5 \mu sec$$) and the third tap is at -10db($$3 \mu sec$$). One way is to resample both the channel response and input data at the same sampling interval but that is way to complex i.e. in this case you will have to interpolate your input signal by 2. Another way is to always match your channel response with the input data sampling rate in this case 1 MHz. But, if you do so with our previous naive method you will miss the 2nd tap. Thus, we will have to interpolate the channel response at $$1 \mu sec$$ from the information given and then pass the input data through it. The sampling rate at which your channel and data is sampled should always be same! The resampling procedure done in IEEE standard document is to produce the correlation among different channel realizations. Answer to your questions are as follows.
Q: Do I need to convolve/filter the data with re-sampled channel coefficients according to the rate of transmitted signal?
A: Yes! You are correct!
Q: should I create only one realization of channel, and use the resulting 3 taps and convolve my data with them?
A: I don't understand your question. If you are to simulate SUI channels, the delay profile says the channel taps are rayleigh distributed i.e. random ! If you fix only one channel there is no randomness and its a static channel.

Hope that helps!

75. Thank you for such a detailed response..!
For my last question, i have data in form of packets. What if I generate 3*1 channel coefficients for every packet instead of 3*10,000 channel coefficients, and regenerate this 3*1 for every packet, then is that a right approach? or I should generate 3*10,000 channel coefficients, then re-sample them according to the sampling rate of data in one packet, then covolve one packet with all the re-sampled channel coefficients? and for rest of packets i should regenerate 3*10,000 channel coefficients and re-sample and repeat this process for every packet. Hope my question is clear.

1. I think what you are discussing here has to do with coherence time of the channel. Coherence time is the time period for which the channel's impulse response stays reasonably constant. Let's assume that you have T_coherence = 5 milliseconds. Now, if your packet length and data rate is such that your one packet duration is less than T_coherence, you can generate one 3-tap channel for every packet. It is example of slow fading channel in which your channel stays constant for your time duration of interest. Suppose now you decrease your data rate such that your packet passes through the channel in longer time. In that case, suppose the length of your packet is 50 milliseconds. Since this time is larger than T_coherence, when your packet is passing through the channel the channel will change. In this case, you will need to generate more independent channel realizations (let's say a matrix of 3 x 20) and impose some sort of correlation among different instances of the channel. This correlation will depend on the doppler in your system. It shows the trade-off between T_coherence and B_coherence (coherence bandwidth, the bandwidth on which channel remains reasonably constant). To make channel look constant for your packet, you will have to increase the data rate so that your packet passes through T_coherence interval but it will increase the bandwidth of your signal. This increased bandwidth will violate the B_coherence of the system and channel will start looking frequency selective. If you decrease the data rate, your channel will start to change in the same packet but you will have the benefit that your signal will lie in the coherence bandwidth of the channel. The design of your system data rate will depend on trading off these two inversely related criteria i.e. T_coherence & B_coherence.

76. Aslam-o-Alaikum Sir,
I want to plot the frequency response of SUI channels. I get delay incorporated (variable number of zeros between taps) 3 taps from a code in Matlab. How can I get frequency information from these taps? i have tries abs(fft) on these taps but somehow i am unable to understand.

1. Consider a signal/channel impulse response 'y' sampled at 'Fs', you can plot the frequence response using

ffty = fftshift(abs(fft(y, N)));
plot([-N/2:N/2-1]*Fs/N, ffty);

choose N for the resolution of your frequency response, e.g., N=256.

2. This comment has been removed by the author.

77. AoA,

i hope you are doing good. i wanted to ask if u could help me about SFO estimation for 802.11n standard. i am currently working on a project in which we have developed an end to end simulation based upon IEEE 802.11n standard. i am unable to find sufficient research papers or literature to find a reliable algorithm for the estimation and correction of SFO (besides the one that i have already implemented but it does not give correct results). Also if u can not help in this, can you help me by checking the algorithm that i have written and see if that is the correct implementation as the algorithm suggests in the respective paper?

1. it stands for Sampling frequency offset or Sampling clock offset

2. If I'm not wrong 802.11n is MIMO-OFDM based and I am afraid I don't know anything about sampling frequency offset estimation in MIMO-OFDM. One of the papers by my advisor is

http://users.ece.gatech.edu/~stuber/nsf3/pubs/stuber/proc-ieee.pdf

and it includes a section on SFO estimation with performance results. If you have anything specific to ask, I may be able to help but checking your complete implementation may not be possible due to the time issues.

78. Dear Obaid,

channel_inv = fft([gain1 gain2 gain3], N);

where gain1, gain2 and gain3 are the gains for 3 tap channel and N is the FFT size.

I was trying this but couldnt get the result as my BER wobbles around 0.5 with snr increases from 0 to 30.

Could you explain to me what could be wrong?

1. Can you elaborate a little more? Which comment of mine are you referring to ? How channel_inv is related to BER? etc.

79. There's a comment in your "Sample spaced multipath channel" by Bari ....i am trying to equalise my signal with channel_inv (as i mentioned in my previous comment) but i think equalisation has not been done properly with this channel_inv. For that reason, BER is 0.5 for all SNRs ....
gain1 = sqrt(powerTap1/2)*[randn (data) + 1j*rand(data)];
same for gain2 and gain3...
channel_inv = fft([gain1 gain2 gain3], N);

any suggestion

1. gain1 = sqrt(powerTap1/2)*[randn (data) + 1j*rand(data)];

in this line the first tap is normally distributed and the second one is uniformly distributed? To make gain1 Rayleigh distributed, make sure both the taps are distributed according to Gaussian pdf. I think you should first make this correction and then see if you still have problem with your simulation.

2. The problem remains .....i was using both randn before but while typing here i forgot to put 'n' in the second rand.

Now please make any clearification about channel equalization. I am using SC-FDMA and when i convolve my delayed version of the signal with faded coefficients i.e. gain1 gain2 gain3 (3 tap channel), i increase my faded signal length. and equalization is not helping me.....

Thank You for ur patience and Time

3. As it appears from your description, you have a longer length of the signal after convolution, and you don't understand how to equalize that longer length. If your OFDM system is adequately designed such that the longest path delay is within the cyclic prefix length, this longer length shouldn't matter. All you need to do at the receiver is to take an N-length FFT window, where N is your FFT length and equalize it using your channel inverse operation. So no matter what the length of your signal is after convolution, you can take the N-length window and equalize it using the method of your choice.