MATLAB: How to read a matrix contain ‘?’

matrix manipulation

I want to read file txt and replace '?' in the current matrix with 0 exempl
File containing this matrix :
A;B;C
?;7;9
9;?;1
1;8;5
==>
A;B;C
0;7;9
9;0;1
1;8;5

Best Answer

fid = fopen('filename.txt')
d = textscan(fid,'%f%f%f', 'Delimiter', ';', 'TreatAsEmpty', '?', 'EmptyValue', 0, 'CollectOutput', 1)
fclose(fid)
out = d{1};