MATLAB: How to use textscan to read data with missing values

emptyvaluemissing valuetextreadtextscan

I found it is not possible to use textscan to import a .txt file while the data itself contains missing values.
So for example, I have a test.txt, where * represents missing data(empty) and the delimiter is just whitespace:
1 2 3 4
5 6 A *
7 8 A *
9 * * 10
Is there any exports can help me?? Thanks a lot!

Best Answer

Does the file contain '*' as markers for empty value, or did you insert the stars here for display purposes only?
If there are no values in the real file, if a value is missing:
Data = textscan(FID, '%f%f%f%f', 'Delimiter', ' ', 'EmptyValue', Inf);
If there are stars in the file, you could use an intermediate step:
Str = fileread(FileName);
Str = strrep(Str, '*', '');
Data = textscan(Str, '%f%f%f%f', 'Delimiter', ' ', 'EmptyValue', Inf);