Why is this error occuring in my code.
1 次查看(过去 30 天)
显示 更早的评论

Index exceeds matrix dimensions.
Error in test2 (line 20) C2(i) = B*log2(1+min(i));
0 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!