for loop returns NaN

6 ビュー (過去 30 日間)
negin tebyani
negin tebyani 2018 年 2 月 10 日
回答済み: Walter Roberson 2018 年 2 月 10 日
I am trying to do this in my code:
for i=1:c+1
load(row) = load(row)+(ro(row,i)* MinRateCurrentUserRRH(row,i))/(log(1+SINR(row,i)));
end
ro is a matrix of 1 and 0 s and MinRateCurrentUserRRH and SINR s are other matrixes. before running the for loop, load (row) is fine and for example 0.3, after first loop, it turns to NaN, so it gives errors, I can't figure out the problem. can anyone help me with it?
  3 件のコメント
negin tebyani
negin tebyani 2018 年 2 月 10 日
編集済み: negin tebyani 2018 年 2 月 10 日
SINR and currnetminrate are zero matrices that are filled in the code in other loops, in the time of running this, they look like:
and
and c is 1.
dpb
dpb 2018 年 2 月 10 日
As other poster says, nothing anybody here can do without actual data but you've got all the information you need; just use the debugger and see where your logic fails.
While not the specific problem, you can probably replace all the loops with Matlab array operations; "the MATLAB way". Look at the "dot" operators under
>> help punct
Punctuation.
. Decimal point. 325/100, 3.25 and .325e1 are all the same.
. Array operations. Element-by-element multiplicative operations
are obtained using .* , .^ , ./ , .\ or .'. For example,
C = A ./ B is the matrix with elements c(i,j) = a(i,j)/b(i,j).
...

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2018 年 2 月 10 日
Your row is a vector, so (log(1+SINR(row,i)) is a vector, so your / operator is mrdivide, the matrix right division operator, with A/B being approximately equivalent to A * pinv(B) where the * indicates mtimes, the algebraic matrix multiplication operator. For vector row you need the ./ operator instead of /
You will also need to watch out for the * operator earlier in the line: you probably want it to be .*

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by