フィルターのクリア

Why is this error occuring in my code.

1 回表示 (過去 30 日間)
Muneeb Ahmad
Muneeb Ahmad 2017 年 11 月 2 日
編集済み: KL 2017 年 11 月 2 日
Index exceeds matrix dimensions.
Error in test2 (line 20) C2(i) = B*log2(1+min(i));

採用された回答

KL
KL 2017 年 11 月 2 日
編集済み: KL 2017 年 11 月 2 日
you're getting the error because you forgot to index B,
C2(i) = B(i)*log2(1+min(i))
But anyway, what do you even mean by min(i), i in your case is just a scalar.
I'd recommend you to rename the loop varible , i, to something else since i is the default imaginary unit in matlab. Nextly, pre-allocate A, B, C2 and d properly. For example,
A = zeros(1,length(ro_db))
TIP: when you see read underlines on your code, it means matlab is trying to help you by giving some warning and even recommendations, do not ignore them.
  2 件のコメント
Muneeb Ahmad
Muneeb Ahmad 2017 年 11 月 2 日
Subscript indices must either be real positive integers or logicals.
Error in test2 (line 18) C2(i) = B*log2(1+(min(A,B)));
still getting this error others things are ok now.
KL
KL 2017 年 11 月 2 日
編集済み: KL 2017 年 11 月 2 日
Again, you're not indexing A or B in your equation!
C2(i) = B(i)*log2(1+min(A(i),B(i)))

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by