MATLAB: How i can get the first and second letters in cell data

how i can get the first and second letters in cell data

hello all;
i want to get the first and second letters of each row
letters={'Aliadan';'FadumoHassan'; 'Buraaleabi';'kadradahir'};
so, how i can assign first charac of each row in one vector and the second character in each row in another vector.

Best Answer

This can be easily achieved using cellfun and a simple anonymous function:
>> vec = {'Aliadan'; 'FadumoHassan'; 'Buraaleabi'; 'kadradahir'};
>> cellfun(@(s)s(1),vec)
ans =
A
F
B
k
>> cellfun(@(s)s(2),vec)
ans =
l
a
u
a