I have a cell array, x, and each row of which is a string array.
For instance,
>>ab = x{2};
>>ab
ans =
910 Flow’S Equation
Clearly, this string has a pattern: a numerical value and a text string are separated by some empty spaces. With respect to this example, when I type
>> ab(2)
ans =
1
>> ab(3)
ans =
0
>> ab(6)
ans =
F
In my code, I need automatically check the starting position of text string, which is the one for “F” and the end position of numerical value, which is the one for “0”. I use
>> x = strfind(ab, ' ');
For this example, I expect it give me the positions of “space” as
4 5 12
In stead, it just gives me 12 without outputing 4 and 5
I think the problem is that the fourth and fifth entries of ab are not “space”, How can I know what are they? When I type
>> ab(4)
ans =
The output is nothing, just like what “space” is?
To find out what char
ab(4)is, convert the char to numerical form byFor
double(ab(4))=9, it’s aTAB. If your string is ASCII, you may want to check ASCII control characters and ASCII printable characters for the mapping.However, to find the beginning of the text string, using
regexpmay be a better idea:regexp(ab, '[^\d\s]')returns the locations of all characters that are neither numbers nor white spaces, and the minimum of the locations should be where the text begins.