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 个评论
KL
KL 2017-12-11
For versions 16b+, you could simply write,
alfa = reshape(hh./(2*b.'),1,[]);

请先登录,再进行评论。

回答(3 个)

ME
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?

Guillaume
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!

Berk B
Berk B 2017-12-11
Thanks for answers, I fixed it by attaching one more hh matrix.

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by