Professional Documents
Culture Documents
Arreglos Matrices
Arreglos Matrices
Arreglos Matrices
>> A = [1 2 3; 4 5 6]
A =
1 2 3
4 5 6
>> A(1,1)
ans =
>> A(1,end)
ans =
>> A(2,2)
ans =
>> A = [1 2 3; 4 5 6];
>> A (2,:)
ans =
4 5 6
>> A (:,2)
ans =
2
5
>> A = [1 2 3; 4 5 6]
A =
1 2 3
4 5 6
>> A (2,2:3)
ans =
5 6
MATLAB Command Window Page 2
>> A (2, [3 1] )
ans =
6 4
>> A ( [2 1] , 2:3)
ans =
5 6
2 3
>> A (end, [1 3] )
ans =
4 6
>> A = [1 2 3; 4 5 6] ;
>> A(5)
ans =
>> A=[1 2 3 4 5]
A =
1 2 3 4 5
>> B=1:2:9
B =
1 3 5 7 9
>> T = [ A; B]
T =
1 2 3 4 5
1 3 5 7 9
>> A = [ ]
A =
[]
MATLAB Command Window Page 3
>> B = 4:-1:5;
>> M = [1 2 3 ;4 5 6 ];
>> A=M(:)
A =
1
4
2
5
3
6
>> M = [1 2 3; 4 5 6; 7 8 9];
>> M(1,5)=3
M =
1 2 3 0 3
4 5 6 0 0
7 8 9 0 0
ans =
0 0 0
0 0 0
0 0 0
ans =
0 0 0 0 0
0 0 0 0 0
ans =
1 1 1
1 1 1
>> eye(3)
ans =
1 0 0
0 1 0
MATLAB Command Window Page 4
0 0 1
>> magic(3)
ans =
8 1 6
3 5 7
4 9 2
>> A=magic(3)
A =
8 1 6
3 5 7
4 9 2
>> M=A>4
M =
1 0 1
0 1 1
0 1 0
>> A=magic(3)
A =
8 1 6
3 5 7
4 9 2
>> m=find(A>4)
m =
1
5
6
7
8
>> A(m)=10*ones(size(m))
A =
10 1 10
MATLAB Command Window Page 5
3 10 10
4 10 2
x =
1 2 3 4 NaN 6
>> i=find(isnan(x))
i =
>> x(isnan(x))=[]
x =
1 2 3 4 6
>> x=x(find(~isnan(x)));
>> A(any(isnan(A)'), :)=[]
A =
10 1 10
3 10 10
4 10 2
>>