I got an error Index exceeds matrix dimensions.
1 次查看(过去 30 天)
显示 更早的评论
When I ran this script I'm getting an error which I indicated below. Is there someone could help me please?
回答(3 个)
ME
2017-12-11
I have just run the code exactly as given in your problem description and it works absolutely fine for me using R2016a.
It appears as though the code segment you present in your problem description is part of a longer code (hence the issue being at line 88). Have you tried running this segment in isolation to see if it produces the same issue?
0 个评论
Guillaume
2017-12-11
编辑:Guillaume
2017-12-11
I'm not sure which font you're using in your editor/command window but your l (letter el) and your 1 (number 1) look exactly the same, so could it be possible that one of the 1 in the alfa(1,s)=hh(1,i)/(2*b(l,j)) is actually an l and that the l variable does exist (with value > 11)
In any case, as pointed out by KL using a loop for that sort of calculation is a waste of time
alfa = reshape(hh./(2*b.'),1,[]); %R2016b or later
alfa = reshape(bsxfun(@rdivide, hh, 2*b.'), 1, []); %any version
Personally, I would not bother with the reshape and keep alfa as a 11x11 matrix.
I would also recommend switching your UI to a font where 1 and l look clearly different!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!