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

조회 수: 2 (최근 30일)
Prabha Kumaresan
Prabha Kumaresan 2017년 11월 8일
답변: Eric 2017년 11월 9일
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
Kaushik Lakshminarasimhan
Kaushik Lakshminarasimhan 2017년 11월 8일
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?

댓글을 달려면 로그인하십시오.

답변 (1개)

Eric
Eric 2017년 11월 9일
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.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by