copy a line from a txt to other txt
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
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);
0 commentaires
Plus de réponses (0)
Voir également
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!