Try this
str = fileread('cssm.txt');
str = strrep( str, '-;', 'nan;' );
nl = [char(13),char(10)];
str = regexprep( str, [';-\s*',nl], [';nan',nl] );
C = textscan( str,'%s%f%f%f%f%f%f%f%f','headerlines',1,'delimiter',';');
where cssm.txt contains the rows of text in the question
The approach is
- read the whole file as text
- replace the "-", which stands for missing, with NaN
- parse the modified string with textscan
Note: the value of the variable, nl, must match the end of line characters in your file.
Jan, thanks for formatting the question.
Best Answer