how to generate data rates in matlab

11 visualizzazioni (ultimi 30 giorni)
Talha Rahman
Talha Rahman il 26 Ago 2011
Hi there, i would like to know how can i generate data at transmitter and send over the channel at specific data rate. Like i use randint command for data generation at rate of 10kbps(lets say) ....so far what i am doing is
for time_t = 0:inputBlockSize*Tb/Ts*Ts:1
if mod == 'QPSK'
sr = Rb/2;
tmp2 = [];
tmp1 = randint(1,2*inputBlockSize);
tmp = tmp1*2 - 1;
end
......... code goes on and on...........
end % time_t ends here
where inputBlockSize is 16 (say)... time_t is the time that i initialized and at each tick between 0sec to 1sec i generate 16bits where Tb = 1e-4 (data rate is 10kbps) and Ts is any sampling period. is it right definition of introducing data rate?
Does this make sense?
Thanx

Risposte (1)

Rick Rosson
Rick Rosson il 28 Ago 2011
Before jumping into a for loop, you should consider whether it is possible to vectorize this code. MATLAB is really good at handling large vectors and matrices, and performing linear algebra. Think about whether your algorithm can be done on the entire data set all at once, rather than in a massive for loop.
As a first step, you may want to define your time increment as a variable, perhaps called dt, so that you can validate if it is correct. So, for example:
dt = inputBlockSize*Tb/Ts*Ts;
disp(dt);
When MATLAB displays the value of dt, does it make sense to you? Also, notice that in the equation for dt, you first divide by Ts, and then immediately multiply by Ts. Is that really necessary? It would be more efficient to eliminate these two operations entirely:
dt = inputBlockSize*Tb;
disp(dt);
Does this code result in the same value for dt as before? Does this code make sense? Is the value of dt what you were expecting, or is it surprising?
HTH.
Best,
Rick
  1 Commento
Talha Rahman
Talha Rahman il 28 Ago 2011
yea....i eliminate Ts from the equation (as you said) and the value is same as before (of course it should be)....i dont know if i understand your question properly....but what i m doing in my algorithm is i generate inputblocksize of 16 (say) binary bits and i multiply it with bit duration Tb (for 10kbps, it is 1e-4) hence i got time duration of 16 bits ....and once my time_t takes step towards 1 i will transmit 16 bits ...as my for loop time_t reaches 1, i transmitted 1000bits....hence i got 1000bits/1sec.....
By the way, i didn't get what you have said in your first paragraph....apologies ...:(
BR

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by