rand(Nuser,Ncarrier)= (b.*log(1+​(rand(powe​r).*rand(c​g))/noise)​);

2 views (last 30 days)
whether the above expression was correct as i am getting error using rand Size vector should be a row vector with real elements. Nuser->no of users Ncarrier->no of subcarriers cg-channel gain
  1 Comment
Kaushik Lakshminarasimhan
There are so many things wrong with that line of code, I don't know where to begin. Why don't you start by clearly describing the problem you're trying to solve?

Sign in to comment.

Answers (1)

Eric
Eric on 9 Nov 2017
Your equation:
rand(Nuser,Ncarrier)= (b.*log(1+(rand(power).*rand(cg))/noise));
Some observations:
  • rand is a MATLAB function and so it is inadvisable to use it as a variable name. Choose another name. I'll call it rand_Prabha.
  • Because of the previous point, I have no idea if the rand you are intending to use is MATLAB's rand or if you mean rand_Prabha. Either way, passing power and cg is a bad idea because for rand, you need to pass integers to tell rand the output dimensions, and for rand_Prabha, you need to pass integers to tell MATLAB which indicies you want. So either way, power and cg need to be positive integers, which I'm guessing is not what you intended.
Because of these two points, it is impossible to know what exactly you intended to do with your code. My best guess is that power and/or cg are vectors and you wanted to randomly pick a value from them. If that is the case, you may use the following:
rand_Prabha = b.*log1p( ( power(randi(numel(power),Nuser,Ncarrier)) .* ...
cg(randi(numel(cg),Nuser,Ncarrier)) ) ./noise );
This will give you your rand_Prabha with size( rand_Prabha) = [Nuser Ncarier]. If that's not what you are looking for please update your question with a clearer explanation what you are trying to do.

Tags

Community Treasure Hunt

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

Start Hunting!