Matlab - borrar ultima linea de un texto

 
Vista:

borrar ultima linea de un texto

Publicado por alfonso (1 intervención) el 27/06/2013 15:37:03
Hola, tengo un fichero txt con un determinado numero de lineas (numero variable).

Como podria hacer que se borrase la ultima linea de texto del fichero??

Muchas gracias anticipadas
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

borrar ultima linea de un texto

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 28/06/2013 22:59:44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
clear all
fid1=fopen('importandodatostexto21.txt','r');
 i=1;
 while 1
 linea = fgetl(fid1);
 if ~ischar(linea),
     break,
 end
 C{i,1}=linea;
  i=i+1;
 end
fclose(fid1)
 
fid2=fopen('exportandodatostexto24_1.txt','w');
i=0;
for i=1:size(C,1)-1
      fprintf(fid2,'%s\n',C{i,1});
end
fclose(fid2);
edit('importandodatostexto21.txt')
edit('exportandodatostexto24_1.txt')
entrada=importdata('importandodatostexto21.txt')
salida=importdata('exportandodatostexto24_1.txt')


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
>> importandodatostexto24
 
 
entrada =
 
    ' juan'
    ' pedro'
    ' francisco'
    ' marta'
    ' maria'
 
 
salida =
 
    ' juan'
    ' pedro'
    ' francisco'
    ' marta'





Saludos.
JOSE JEREMÍAS CABALLERO
Asesorías en Matlab
programador en matlab
Servicios de programación matlab
[email protected]

http://matlabcaballero.blogspot.com

http://www.lawebdelprogramador.com/foros/Matlab/1371532-FORMA_DE_APRENDER_MATLAB.html
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar