MATLAB: Using find function for char

find

line =
10 L1 L2 L5 C1 C2 P2 C5 S1 S2# / TYPES OF OBSERV
Name Size Bytes Class
line 1×81 162 char
%I need to use find function for each character in line. For example, I need to know which column is L1 or L2.

Best Answer

Do you actually want to find which column of the string where L1 and L2 are, or if L1 is the second element and L2 the third?
If the former, then use Michael's answer. If the latter, then the best thing to do would be to split the string at the whitespaces then use strcmp:
line = '10 L1 L2 L5 C1 C2 P2 C5 S1 S2# / TYPES OF OBSERV';
splitline = strsplit(line);
L1idx = find(strcmp(splitline, 'L1'))
L2idx = find(strcmp(splitline, 'L2'))