Cell evaluate indexing - Index exceeds matrix dimensions.
Show older comments
why this code is generating the error "Index exceeds matrix dimensions"?
% code
a{1} = 90;
i = 1;
a{num2str(i)};
Accepted Answer
More Answers (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.
1 Comment
Birdman
on 28 Nov 2017
Ok, I got it, thanks.
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!