Hola Miren.
Datos del archivo de texto cuyo nombre matrizsepararfilas.txt. Puede ser de cualquier cantidad de columnas y filas, a tu gusto este es un ejemplo en particular. El programa lo va a soportar.
0.5294 0.5246 0.8383 0.8266 0.9081 0.7117 0.7588 0.8090 18 22 23 17
0.8300 0.9727 0.5847 0.6769 0.5522 0.8715 0.9952 0.3565 13 12 3 1
0.8588 0.7104 0.9481 0.2076 0.0329 0.3287 0.1866 0.0732 5 6 2 19
0.7890 0.3119 0.0610 0.3181 0.0539 0.6501 0.7811 0.5910 12 10 8 4
0.3178 0.2915 0.5846 0.1338 0.8051 0.9748 0.1958 0.9102 12 17 14 12
0.4522 0.8504 0.2851 0.6715 0.4514 0.0760 0.9924 0.1938 23 13 13 6
0.7522 0.9116 0.8277 0.5710 0.3826 0.5870 0.8023 0.4324 20 18 21 9
0.1099 0.6393 0.1910 0.1698 0.7896 0.4139 0.4242 0.7492 23 23 13 16
0.1097 0.2554 0.4425 0.1477 0.3643 0.3091 0.7289 0.0392 16 23 10 4
0.2699 0.0887 0.3934 0.4761 0.5323 0.2638 0.4984 0.9463 10 13 13 7
El programa: matrizsepararfilas.m en matllab
%===========================================
clear
A=importdata('matrizsepararfilas.txt');
display(A);
[f,c]=size(A);
fprintf('LAS 4 ULTIMAS COLUMNAS DE LA MATRIZ A SON TIEMPOS:\n');
fprintf('[HORAS MINUTOS SEGUNDOS MILISEGUNDOS]\n')
display('PROBAR CON: horas=12 minutos=23; segundos=13; milisegundos=4;')
horas=input('Ingrese el numero de horas:');
minutos=input('Ingrese el numero de minutos:');
segundos=input('Ingrese el numero de segundos:');
milisegundos=input('Ingrese el numero de milisegundos:');
% horas=12;
% minutos=23;
% segundos=13;
% milisegundos=4;
l=1;
j=1;
k=1;
m=1;
for fil=1:f
if A(fil,c-3)==horas
HORA(m,:)=A(fil,:);
m=m+1;
end
if A(fil,c-2)==minutos
MIN(k,:)=A(fil,:);
k=k+1;
end
if A(fil,c-1)==segundos
SEG(j,:)=A(fil,:);
j=j+1;
end
if A(fil,c)==milisegundos
MILISEG(l,:)=A(fil,:);
l=l+1;
end
end
display(['filas de ',num2str(milisegundos),' milisegundos'])
display(MILISEG)
display(['filas de ',num2str(segundos),' segundos'])
display(SEG)
display(['filas de ',num2str(minutos),' minutos'])
display(MIN)
display(['filas de ',num2str(horas),' horas'])
display(HORA)
%==========================================
EJECUCION DEL PROGRAMA.
%=======================================================
1RA EJECUCION:
>> matrizsepararfilas
A =
0.5294 0.5246 0.8383 0.8266 0.9081 0.7117 0.7588 0.8090 18.0000 22.0000 23.0000 17.0000
0.8300 0.9727 0.5847 0.6769 0.5522 0.8715 0.9952 0.3565 13.0000 12.0000 3.0000 1.0000
0.8588 0.7104 0.9481 0.2076 0.0329 0.3287 0.1866 0.0732 5.0000 6.0000 2.0000 19.0000
0.7890 0.3119 0.0610 0.3181 0.0539 0.6501 0.7811 0.5910 12.0000 10.0000 8.0000 4.0000
0.3178 0.2915 0.5846 0.1338 0.8051 0.9748 0.1958 0.9102 12.0000 17.0000 14.0000 12.0000
0.4522 0.8504 0.2851 0.6715 0.4514 0.0760 0.9924 0.1938 23.0000 13.0000 13.0000 6.0000
0.7522 0.9116 0.8277 0.5710 0.3826 0.5870 0.8023 0.4324 20.0000 18.0000 21.0000 9.0000
0.1099 0.6393 0.1910 0.1698 0.7896 0.4139 0.4242 0.7492 23.0000 23.0000 13.0000 16.0000
0.1097 0.2554 0.4425 0.1477 0.3643 0.3091 0.7289 0.0392 16.0000 23.0000 10.0000 4.0000
0.2699 0.0887 0.3934 0.4761 0.5323 0.2638 0.4984 0.9463 10.0000 13.0000 13.0000 7.0000
LAS 4 ULTIMAS COLUMNAS DE LA MATRIZ A SON TIEMPOS:
[HORAS MINUTOS SEGUNDOS MILISEGUNDOS]
PROBAR CON: horas=12 minutos=23; segundos=13; milisegundos=4;
Ingrese el numero de horas:12
Ingrese el numero de minutos:23
Ingrese el numero de segundos:13
Ingrese el numero de milisegundos:4
filas de 4 milisegundos
MILISEG =
0.7890 0.3119 0.0610 0.3181 0.0539 0.6501 0.7811 0.5910 12.0000 10.0000 8.0000 4.0000
0.1097 0.2554 0.4425 0.1477 0.3643 0.3091 0.7289 0.0392 16.0000 23.0000 10.0000 4.0000
filas de 13 segundos
SEG =
0.4522 0.8504 0.2851 0.6715 0.4514 0.0760 0.9924 0.1938 23.0000 13.0000 13.0000 6.0000
0.1099 0.6393 0.1910 0.1698 0.7896 0.4139 0.4242 0.7492 23.0000 23.0000 13.0000 16.0000
0.2699 0.0887 0.3934 0.4761 0.5323 0.2638 0.4984 0.9463 10.0000 13.0000 13.0000 7.0000
filas de 23 minutos
MIN =
0.1099 0.6393 0.1910 0.1698 0.7896 0.4139 0.4242 0.7492 23.0000 23.0000 13.0000 16.0000
0.1097 0.2554 0.4425 0.1477 0.3643 0.3091 0.7289 0.0392 16.0000 23.0000 10.0000 4.0000
filas de 12 horas
HORA =
0.7890 0.3119 0.0610 0.3181 0.0539 0.6501 0.7811 0.5910 12.0000 10.0000 8.0000 4.0000
0.3178 0.2915 0.5846 0.1338 0.8051 0.9748 0.1958 0.9102 12.0000 17.0000 14.0000 12.0000
%=============================================================
%==========================================================
2DA EJECUCION:
>> matrizsepararfilas
A =
0.5294 0.5246 0.8383 0.8266 0.9081 0.7117 0.7588 0.8090 18.0000 22.0000 23.0000 17.0000
0.8300 0.9727 0.5847 0.6769 0.5522 0.8715 0.9952 0.3565 13.0000 12.0000 3.0000 1.0000
0.8588 0.7104 0.9481 0.2076 0.0329 0.3287 0.1866 0.0732 5.0000 6.0000 2.0000 19.0000
0.7890 0.3119 0.0610 0.3181 0.0539 0.6501 0.7811 0.5910 12.0000 10.0000 8.0000 4.0000
0.3178 0.2915 0.5846 0.1338 0.8051 0.9748 0.1958 0.9102 12.0000 17.0000 14.0000 12.0000
0.4522 0.8504 0.2851 0.6715 0.4514 0.0760 0.9924 0.1938 23.0000 13.0000 13.0000 6.0000
0.7522 0.9116 0.8277 0.5710 0.3826 0.5870 0.8023 0.4324 20.0000 18.0000 21.0000 9.0000
0.1099 0.6393 0.1910 0.1698 0.7896 0.4139 0.4242 0.7492 23.0000 23.0000 13.0000 16.0000
0.1097 0.2554 0.4425 0.1477 0.3643 0.3091 0.7289 0.0392 16.0000 23.0000 10.0000 4.0000
0.2699 0.0887 0.3934 0.4761 0.5323 0.2638 0.4984 0.9463 10.0000 13.0000 13.0000 7.0000
LAS 4 ULTIMAS COLUMNAS DE LA MATRIZ A SON TIEMPOS:
[HORAS MINUTOS SEGUNDOS MILISEGUNDOS]
PROBAR CON: horas=12 minutos=23; segundos=13; milisegundos=4;
Ingrese el numero de horas:18
Ingrese el numero de minutos:10
Ingrese el numero de segundos:8
Ingrese el numero de milisegundos:12
filas de 12 milisegundos
MILISEG =
0.3178 0.2915 0.5846 0.1338 0.8051 0.9748 0.1958 0.9102 12.0000 17.0000 14.0000 12.0000
filas de 8 segundos
SEG =
0.7890 0.3119 0.0610 0.3181 0.0539 0.6501 0.7811 0.5910 12.0000 10.0000 8.0000 4.0000
filas de 10 minutos
MIN =
0.7890 0.3119 0.0610 0.3181 0.0539 0.6501 0.7811 0.5910 12.0000 10.0000 8.0000 4.0000
filas de 18 horas
HORA =
0.5294 0.5246 0.8383 0.8266 0.9081 0.7117 0.7588 0.8090 18.0000 22.0000 23.0000 17.0000
%===========================================================
Saludos.
JOSE JEREMIAS CABALLERO
ASESOR DE PROYECTOS CON MATLAB
PROFESOR DE METODOS NUMERICOS CON MATLAB
PROGRAMADOR EN MATLAB
[email protected]