how save diplayed data?

1 visualización (últimos 30 días)
huda nawaf
huda nawaf el 6 de Abr. de 2012
hi,
i have the following code:
fid=fopen('webscopG.txt');
for j=1:100000
tline = fgetl(fid);
i=i+1;
if ~ischar(tline), break, end
disp(tline);
end
fclose(fid);
this code will display tline as array, and that what I need . But how I can save this array of tline.
thanks
  2 comentarios
Image Analyst
Image Analyst el 6 de Abr. de 2012
Save it how? In a different text file? In a .mat file?
huda nawaf
huda nawaf el 12 de Abr. de 2012
text file

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 6 de Abr. de 2012
If you are unable to modify that source, then consider the diary command, or consider executing that source within evalc() and writing out the characters you get back from evalc().
Much better would be to follow IA's suggestion of writing to a file within the loop itself. fopen(), fprintf(), eventually fclose()
  6 comentarios
huda nawaf
huda nawaf el 13 de Abr. de 2012
many thanks walter,
Now I want to save tlines from sepecific position,i.e I do not print it from first line. what i have to do?
thanks
Walter Roberson
Walter Roberson el 13 de Abr. de 2012
if (i >= RangeStart) && (i <= RangeEnd); fprintf(....); end

Iniciar sesión para comentar.

Más respuestas (2)

Thijs
Thijs el 6 de Abr. de 2012
fid=fopen('webscopG.txt');
for j=1:100000
tline{i} = fgetl(fid);
i=i+1;
if ~ischar(tline),
break,
end
disp(tline);
end fclose(fid);
does that work?
  1 comentario
Walter Roberson
Walter Roberson el 6 de Abr. de 2012
No, you cannot have "fclose" in the same statement as "end".

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 6 de Abr. de 2012
Maybe open a second file for writing and write it out with fprintf()?
  1 comentario
huda nawaf
huda nawaf el 12 de Abr. de 2012
I can not do that, because the tline save just last line

Iniciar sesión para comentar.

Categorías

Más información sobre Resizing and Reshaping Matrices 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