How can I read a matrix contain '?'

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

 Accepted Answer

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

More Answers (1)

fid=fopen('filename.txt')
d=textscan(fid,'%s')
fclose(fid)
out=strrep(d{1},'?','0')

3 Comments

this out is possible to manipulate it like a matrix not string like ==> out(1,2)
Data are imported like shown in your question
yes but this is not a matrix this is set of strings i can't manipulate it

Sign in to comment.

Categories

Asked:

MED
on 7 Dec 2013

Commented:

MED
on 7 Dec 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!