How can I read a matrix contain '?'

3 vues (au cours des 30 derniers jours)
MED
MED le 7 Déc 2013
Commenté : MED le 7 Déc 2013
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

Réponse acceptée

Walter Roberson
Walter Roberson le 7 Déc 2013
fid = fopen('filename.txt')
d = textscan(fid,'%f%f%f', 'Delimiter', ';', 'TreatAsEmpty', '?', 'EmptyValue', 0, 'CollectOutput', 1)
fclose(fid)
out = d{1};
  1 commentaire
MED
MED le 7 Déc 2013
Perfect !!!

Connectez-vous pour commenter.

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 7 Déc 2013
fid=fopen('filename.txt')
d=textscan(fid,'%s')
fclose(fid)
out=strrep(d{1},'?','0')
  3 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 7 Déc 2013
Data are imported like shown in your question
MED
MED le 7 Déc 2013
yes but this is not a matrix this is set of strings i can't manipulate it

Connectez-vous pour commenter.

Catégories

En savoir plus sur Large Files and Big Data dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by