As you have an array containing both numeric and character data, what you want is impossible (and trust me, it would be impractical, too).
Referencing individual numbers in a numeric array is different from referencing whole strings. There is simply no escaping that, nor should there be: you treat flowers differently from how you treat people (I sure hope so anyway).
In MATLAB, a string is an ordinary array, with the difference that each entry of the array does not represent a number, but a character. Referencing individual characters goes the same as referencing numbers in arrays:
>> a = 'my string'
>> a(4)
ans =
s
>> a+0 % cast to double to show the "true character" of strings
ans =
109 121 32 115 116 114 105 110 103
However, textscan
assumes (rightfully so) that you don't want to do that, but rather you want to extract whole strings from the file. And whole strings should be referenced differently, to indicate that you mean whole strings and not individual characters.
I think you'll find it all a bit more intuitive if you split the results from textscan
up into an ordinary numeric array and a cell array of strings, like so:
% load the data
ftest = fopen('test.csv');
C = textscan(ftest,...
'%f %s %f %f %f %f %f %f %s %s %f %f',...
'collectoutput', true,...
'Delimiter',',\n');
fclose(ftest);
% split into numeric and char arrays
numeric = [C{[1 3 5]}]
alpha = [C{[2 4]}]
Referencing data in numeric
then follows the same rules as any ordinary array, and referencing the strings in alpha
then follows the normal cell-referencing rules (as in alpha{2,1}
to get '03/05/1986'
)
EDIT Based no your comments, you want to do the conversion like this:
% Read the data
fid = fopen('test.csv', 'r');
C = textscan(fid,...
'%f %s %f %f %f %f %f %f %s %s %f %f',...
'Headerlines', 1,...
'Delimiter',',');
fclose(fid);
% Delete 10th element ('ASC')
C(10) = [];
% Mass-convert dates to datenums
C{2} = datenum(C{2}, 'dd/mm/yyyy');
% Map 'P' to 1 and 'C' to 2
map('PC') = [1 2];
C{9} = map([C{9}{:}]).';
% Convert whole array to numeric array
C = [C{:}];