Cell evaluate indexing - Index exceeds matrix dimensions.
显示 更早的评论
why this code is generating the error "Index exceeds matrix dimensions"?
% code
a{1} = 90;
i = 1;
a{num2str(i)};
采纳的回答
更多回答(1 个)
You can use char variables as index, but they are converted to their ASCII value at first:
disp(double('a'));
x = 1:100;
disp(x('a')); % 97
So in your example the problem is, that the char '1' is interpreted as the numerical value 49 and a{49} does not exist.
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!