Reputation: 363
This is a simple snippet to create an cell array and initialize it. I got the following error and it confuses me. Many thanks for your time and attention.
>> o={};
>> a=1:9; b=0;
>> o{end}={a}
Cell contents indices must be greater than 0
>> o{end}=a;
Cell contents indices must be greater than 0
Upvotes: 0
Views: 2803
Reputation: 169
Your issue is very simple: o
contains nothing, so the end
enumerator will return element number 0, which isn't a valid index. What you want is either o{end+1}=a
, or more simply, o{1}=a
.
Upvotes: 3