Effacer les filtres
Effacer les filtres

Using a function strncmp

1 vue (au cours des 30 derniers jours)
MIHYUN
MIHYUN le 16 Jan 2014
Commenté : MIHYUN le 22 Jan 2014
I have a Text file.
And I want to ignore if the first character of the line begins with #.
Also if it begins without # , I want to output.
The code I wrote is as follows .
fid=fopen('asdf1.txt', 'r');
tline=fgetl(fid);
while ischar(tline)
if strncmp(tline,'#',1);%%this part is problem.
Please tell me what to do.
Thank in advance.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 16 Jan 2014
Modifié(e) : Azzi Abdelmalek le 16 Jan 2014
out=[];
fid=fopen('asdf1.txt');
tline=fgetl(fid);
while ischar(tline)
if ~strncmp(tline,'#',1);
out{end+1}=tline;
end
tline=fgetl(fid);
end
fclose(fid)
But you can just compare them with
if tline(1)=='#"
  1 commentaire
MIHYUN
MIHYUN le 22 Jan 2014
Thank you for your help.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Fourier Analysis and Filtering 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