copy a line from a txt to other txt

1 vue (au cours des 30 derniers jours)
jose bernardo
jose bernardo le 8 Nov 2013
Hello:
I have this code witch copy all lines of a file(fid01)to other file(fid02)
tline = fgetl(fid01);
while ischar(tline)
disp(tline)
fprintf(fid02,'%s\r\n',tline);
tline = fgetl(fid01);
end
fclose(fid01);
fclose(fid02);
How I can change this code to copy only the third line of fid01 to fid02???
Thanks

Réponse acceptée

Simon
Simon le 8 Nov 2013
Hi!
count = 1;
tline = fgetl(fid01);
while ischar(tline)
count = count + 1;
disp(tline)
if count == 3
fprintf(fid02,'%s\r\n',tline);
end
tline = fgetl(fid01);
end
fclose(fid01);
fclose(fid02);
You can do as well
for n = 1:3
tline = fgetl(fid01);
end
fprintf(fid02,'%s\r\n',tline);
fclose(fid01);
fclose(fid02);

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots 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