How can I read a matrix contain '?'

조회 수: 1 (최근 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개)

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 CenterFile Exchange에서 Large 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