Utilizaremos la siguiente matriz como guía, y las siguientes operaciones:
M = [11 35 96
27 86 14
47 59 92
81 67 71]
N=mean(M)
N=[ 41.5 61.75 68.25]
O=M-N
O=[ -30.5 -26.75 27.75
-14.5 24.25 -54.25
5.5 -2.75 23.75
39.5 5.25 2.75]
5.1. Absoluto – abs
P=abs(O)
P=[ 30.5 26.75 27.75
14.5 24.25 54.25
5.5 2.75 23.75
39.5 5.25 2.75]
5.2. Signo – sign
Q=sign(O)
Q=[ -1 -1 1
-1 1 -1
1 -1 1
1 1 1]
5.3. Ordenar ascendente – sort
R=sort(M)
R=[11 35 14
27 59 71
47 67 92
81 86 96]
5.4. Ordenar descendente – sort( , 'descend')
S=sort(M,'descend')
S=[81 86 96
47 67 92
27 59 71
11 35 14]
5.5. Ordenar una matriz en base a una columna especifica – sortrows
R1= sortrows(M,3)
R1=[27 86 14
81 67 71
47 59 92
11 35 96]
5.6. Ordenar una matriz en forma descendente en base a una columna especifica – sortrows( , 'descend')
S1= sortrows(M,3,'descend')
S1=[11 35 96
47 59 92
81 67 71
27 86 14]
5.7. Repetir – repmat
U1=repmat(T,2)
U1=[ 1 2 3 4 1 2 3 4
5 6 7 8 5 6 7 8
1 2 3 4 1 2 3 4
5 6 7 8 5 6 7 8]
U2= repmat(T,1,2)
U2=[1 2 3 4 1 2 3 4
5 6 7 8 5 6 7 8]
U3=repmat(T(:,2),1,3)
U3=[2 2 2
6 6 6]
U4=repmat(T(2,3),1,4)
U4=[7 7 7 7]
5.8. Reacomodar – reshape
Nota: Toma los datos por columnas
V1=reshape(T,[],1)
V1=[ 1
5
2
6
3
7
4
8]
V2=reshape(T,1,[])
V2=[ 1 5 2 6 3 7 4 8]
V3=reshape(T,4,[])
V3=[1 3
5 7
2 4
6 8]
5.9. Eliminar valores repetidos - unique
W=unique (U1)
W=[1;2;3;4;5;6;7;8]
5.10. Eliminar valores repetidos conservando el orden - unique( , 'stable')
X=unique(U1,'stable')
X=[1;5;2;6;3;7;4;8]
5.11. Solicitar entrada de usuario - input
Y= input('Escribir matriz: ')
5.12. Mostrar resultado - disp
Z=disp(Y)
Creado por: Laura BP 2020/04/10