One solution to this issue is to use a regular expression to parse the character matrix.
Suppose we start with the following 2xN character array, where N is the number of characters in each row.
A = ['abc 46 6 ghi'; 'def 7 89 jkl'];
As a first step, we use the REGEXP command to parse array 'A' for numeric-valued strings, including floating point values with the following regular expression:
y = regexp(cellstr(A),'\d+','match')
The output 'y' contains the numeric data as a cell array:
y =
{1x2 cell}
{1x2 cell}
Next, you can convert this cell array to a numeric one using the STR2NUM command and then work on your application without having to write out to a file or iterate through rows to use TEXTREAD or SSCANF.
Best Answer