How can I read a matrix contain '?'

3 ビュー (過去 30 日間)
MED
MED 2013 年 12 月 7 日
コメント済み: MED 2013 年 12 月 7 日
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

採用された回答

Walter Roberson
Walter Roberson 2013 年 12 月 7 日
fid = fopen('filename.txt')
d = textscan(fid,'%f%f%f', 'Delimiter', ';', 'TreatAsEmpty', '?', 'EmptyValue', 0, 'CollectOutput', 1)
fclose(fid)
out = d{1};
  1 件のコメント
MED
MED 2013 年 12 月 7 日
Perfect !!!

サインインしてコメントする。

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 7 日
fid=fopen('filename.txt')
d=textscan(fid,'%s')
fclose(fid)
out=strrep(d{1},'?','0')
  3 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 7 日
Data are imported like shown in your question
MED
MED 2013 年 12 月 7 日
yes but this is not a matrix this is set of strings i can't manipulate it

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by