Reputation: 51
I have a cell with value WORD = '00000'
. But I just want to take the 4th and 5th value.
I already tried KATA=WORD(4:5)
,
I also tried KATA=WORD{4}
But still cannot.
I got this error message :
Index exceeds matrix dimensions.
How to split it? It's in <cell>
type.
Upvotes: 0
Views: 108
Reputation: 47392
You might have something like this
>> word = {'00000'};
This is a 1x1 cell array containing a 1x5 char array. To index into the char array, you first need to index into the cell array, which you do with
>> word{1}
ans =
00000
And now you can index the 4th and 5th element
>> word{1}(4:5)
ans =
00
Upvotes: 1
Reputation: 25232
First you need to index the content of "first" (and only) cell element with curly brackets {}
and then you can index the vector ()
. Therefore you need:
WORD = {'12345'}
output = WORD{1}(4:5)
which gives:
output =
45
Upvotes: 2