Borrar filtros
Borrar filtros

Using a function strncmp

1 visualización (últimos 30 días)
MIHYUN
MIHYUN el 16 de En. de 2014
Comentada: MIHYUN el 22 de En. de 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.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 16 de En. de 2014
Editada: Azzi Abdelmalek el 16 de En. de 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 comentario
MIHYUN
MIHYUN el 22 de En. de 2014
Thank you for your help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by