You have A
defined as:
>> A={'Tom', 'Student'; 'Jim', 'Faculty'; 'Clare', 'Student'}
A =
'Tom' 'Student'
'Jim' 'Faculty'
'Clare' 'Student'
To add a column:
>> newCellCol = strsplit(num2str(1:size(A,1)))'
newCellCol =
'1'
'2'
'3'
>> A = [newCellCol A]
A =
'1' 'Tom' 'Student'
'2' 'Jim' 'Faculty'
'3' 'Clare' 'Student'
>>
For numeric arrays in the first column instead:
>> newCellCol = mat2cell(1:size(A,1),1,ones(1,size(A,1)))';
>> A = [newCellCol A]
A =
[1] 'Tom' 'Student'
[2] 'Jim' 'Faculty'
[3] 'Clare' 'Student'
You can also use num2cell(1:size(A,1))'
in place of mat2cell
above, as noted by Dan.