SoloCodigo
Programación Específica => Matlab => Mensaje iniciado por: tomryddle9999 en Jueves 2 de Junio de 2011, 18:55
-
Ayuda por favor necesito leer una matriz en un archivo de texto con la siguiente sintaxis
0.1, 0.2, 0.5. 0.4,0.5, 0.6,1.2,"0F"
0.5,0.6,0.7,1.1,1.2,1.3,1.4,1.5,"5F"
El problema es que no tengo como un filtro que me quite todo excepto los numeros
ya probe con str2num
con muchas funciones y ninguna me sirve ayuda por favor
:argh: :hitcomp:
-
HOLA.
Archivo de texto. importandodatatxt2.txt
0.1, 0.2, 0.5, 0.4, 0.5, 0.6,1.2,"0F"
0.5, 0.6, 0.7, 1.1, 1.2, 1.3,1.4,"5F"
PROGRAMA EN MATLAB
%==========================================================
clear,
fid=fopen('importandodatatxt2.txt');
i=1;
while 1
linea = fgetl(fid);
if ~ischar(linea),
break,
end
C(i,:)=linea(1,1:end-5);
i=i+1;
end
fclose(fid);
v=find(C==',');
C(v)=' ';
C=str2num(C)
%===============================================
EJECUCION:
>> importandodatatxt2
C =
0.1000 0.2000 0.5000 0.4000 0.5000 0.6000 1.2000
0.5000 0.6000 0.7000 1.1000 1.2000 1.3000 1.4000
Saludos.
JOSE JEREMIAS CABALLERO
ASESOR DE PROYECTOS CON MATLAB
PROFESOR DE METODOS NUMERICOS CON MATLAB
PROGRAMADOR EN MATLAB
jjcc94@hotmail.com