Comandos Import Antes y Simbolos en Matrices

21
Comandos importantes y simbolos en matrices: v(:) Representa todos los elementos de un renglón o una columna de un vector V(:,:) Representa todos los elementos de un renglón o una columna de una matriz V(2:5) Representa los elementos segundo al quinto del vector: v(2), v(3), v(4) y v(5) A(:,3) Denota o toma en cuenta a todos los elementos en la tercera columna de la matriz A. A( :, 2:5) Denota todos los elementos de las columnas segunda a la quinta de la matriz A. A(1:3,3:4) Denota todos los elementos de las filas 1 a 3 y al mismo tiempo que cumplan con pertenecer a las columnas tercera a cuarta.

Transcript of Comandos Import Antes y Simbolos en Matrices

Page 1: Comandos Import Antes y Simbolos en Matrices

Comandos importantes y simbolos en matrices:

v(:) Representa todos los elementos de un renglón o una columna de un vector

V(:,:) Representa todos los elementos de un renglón o una columna de una matriz

V(2:5) Representa los elementos segundo al quinto del vector: v(2), v(3), v(4) y v(5)

A(:,3) Denota o toma en cuenta a todos los elementos en la tercera columna de la matriz A.

A( :, 2:5) Denota todos los elementos de las columnas segunda a la quinta de la matriz A.

A(1:3,3:4) Denota todos los elementos de las filas 1 a 3 y al mismo tiempo que cumplan con pertenecer a las columnas tercera a cuarta.

Page 2: Comandos Import Antes y Simbolos en Matrices

B=[2 4 10 13; 16 3 7 18; 8 4 9 25; 3 12 15 17]

B =

2 4 10 13

16 3 7 18

8 4 9 25

3 12 15 17

>> C= B(2:3,1:3)

C =

16 3 7

8 4 9

>> B=(2,4)

??? B=(2,4)

|

Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

>> B(2,4)

ans =

18

Page 3: Comandos Import Antes y Simbolos en Matrices

>> A=[6,9,4;1,5,7]

A =

6 9 4

1 5 7

>> A(1,5)=3

A =

6 9 4 0 3

1 5 7 0 0

>> A(2,4)=8

A =

6 9 4 0 3

1 5 7 8 0

>> max(B)

ans =

Page 4: Comandos Import Antes y Simbolos en Matrices

16 12 15 25

>> B

B =

2 4 10 13

16 3 7 18

8 4 9 25

3 12 15 17

>> MaB=max(B)

MaB =

16 12 15 25

>> Maxel=

??? Maxel=

|

Error: Expression or statement is incomplete or incorrect.

>> Maxel= max(MaB)

Maxel =

Page 5: Comandos Import Antes y Simbolos en Matrices

25

>> max(max(B))

ans =

25

>> min (B)

ans =

2 3 7 13

>> min(min(min(B))

??? min(min(min(B))

|

Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

>> min(min(min(B)

??? min(min(min(B)

|

Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

>> min(min(B))

Page 6: Comandos Import Antes y Simbolos en Matrices

ans =

2

>> size(B)

ans =

4 4

>> sort(B)

ans =

2 3 7 13

3 4 9 17

8 4 10 18

16 12 15 25

>> B

B =

2 4 10 13

16 3 7 18

8 4 9 25

Page 7: Comandos Import Antes y Simbolos en Matrices

3 12 15 17

>> Bord= sort(B)

Bord =

2 3 7 13

3 4 9 17

8 4 10 18

16 12 15 25

>> sum (B)

ans =

29 23 41 73

>> B'

ans =

2 16 8 3

4 3 4 12

10 7 9 15

13 18 25 17

Page 8: Comandos Import Antes y Simbolos en Matrices

>> max (B)

ans =

16 12 15 25

>> [x,k]=max (B)

x =

16 12 15 25

k =

2 4 4 3

>> [x,l]=min (B)

x =

2 3 7 13

l =

Page 9: Comandos Import Antes y Simbolos en Matrices

1 2 2 1

>> size(b)

??? Undefined function or variable 'b'.

>> size(B)

ans =

4 4

>> ind=find(max(max(B))

??? ind=find(max(max(B))

|

Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

>> indices=find(max(max(B))

??? indices=find(max(max(B))

|

Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

>> indices=find(max(B))

indices =

1 2 3 4

Page 10: Comandos Import Antes y Simbolos en Matrices

>> vmaxB=Max (B)

??? Undefined function or method 'Max' for input arguments of type 'double'.

>> vmaxB=max(B)

vmaxB =

16 12 15 25

>>

Page 11: Comandos Import Antes y Simbolos en Matrices

>> [x,k]=max (B)

x =

16 12 15 25

k =

2 4 4 3

>> vmaxB

vmaxB =

16 12 15 25

>> [x1,k1]=max(VmaxB)

??? Undefined function or variable 'VmaxB'.

>>

>> [x1,k1]=max(vmaxB)

x1 =

25

Page 12: Comandos Import Antes y Simbolos en Matrices

k1 =

4

>> [y1,11]=min(min(B))

??? Error: An array for multiple LHS assignment cannot contain numeric value.

>> [y1,11]=min(min(B))

??? Error: An array for multiple LHS assignment cannot contain numeric value.

>> A=[2,9;5,-7]

A =

2 9

5 -7

>> 3*A

ans =

6 27

15 -21

Page 13: Comandos Import Antes y Simbolos en Matrices

>> r=[3,5,2];v=[2,-3,1]

v =

2 -3 1

>> w=r+v

w =

5 2 3

>> B=[9,8;-12,14]

B =

9 8

-12 14

>> A+B

ans =

11 17

-7 7

Page 14: Comandos Import Antes y Simbolos en Matrices

>> A

A =

2 9

5 -7

>> A*B

ans =

-90 142

129 -58

>> A.*B

ans =

18 72

-60 -98

>> A./B

ans =

0.2222 1.1250

Page 15: Comandos Import Antes y Simbolos en Matrices

-0.4167 -0.5000

>> A/B

ans =

0.6126 0.2928

-0.0631 -0.4640

>> help /

Operators and special characters.

Arithmetic operators.

plus - Plus +

uplus - Unary plus +

minus - Minus -

uminus - Unary minus -

mtimes - Matrix multiply *

times - Array multiply .*

mpower - Matrix power ^

power - Array power .^

mldivide - Backslash or left matrix divide \

mrdivide - Slash or right matrix divide /

ldivide - Left array divide .\

rdivide - Right array divide ./

idivide - Integer division with rounding option.

Page 16: Comandos Import Antes y Simbolos en Matrices

kron - Kronecker tensor product

Relational operators.

eq - Equal ==

ne - Not equal ~=

lt - Less than <

gt - Greater than >

le - Less than or equal <=

ge - Greater than or equal >=

Logical operators.

relop - Short-circuit logical AND &&

relop - Short-circuit logical OR ||

and - Element-wise logical AND &

or - Element-wise logical OR |

not - Logical NOT ~

punct - Ignore function argument or output ~

xor - Logical EXCLUSIVE OR

any - True if any element of vector is nonzero

all - True if all elements of vector are nonzero

Special characters.

colon - Colon :

paren - Parentheses and subscripting ( )

paren - Brackets [ ]

paren - Braces and subscripting { }

Page 17: Comandos Import Antes y Simbolos en Matrices

punct - Function handle creation @

punct - Decimal point .

punct - Structure field access .

punct - Parent directory ..

punct - Continuation ...

punct - Separator ,

punct - Semicolon ;

punct - Comment %

punct - Invoke operating system command !

punct - Assignment =

punct - Quote '

transpose - Transpose .'

ctranspose - Complex conjugate transpose '

horzcat - Horizontal concatenation [,]

vertcat - Vertical concatenation [;]

subsasgn - Subscripted assignment ( ),{ },.

subsref - Subscripted reference ( ),{ },.

subsindex - Subscript index

metaclass - Metaclass for MATLAB class ?

Bitwise operators.

bitand - Bit-wise AND.

bitcmp - Complement bits.

bitor - Bit-wise OR.

bitmax - Maximum floating point integer.

bitxor - Bit-wise XOR.

Page 18: Comandos Import Antes y Simbolos en Matrices

bitset - Set bit.

bitget - Get bit.

bitshift - Bit-wise shift.

Set operators.

union - Set union.

unique - Set unique.

intersect - Set intersection.

setdiff - Set difference.

setxor - Set exclusive-or.

ismember - True for set member.

See also arith, relop, slash, function_handle.

>> inv (B)

ans =

0.0631 -0.0360

0.0541 0.0405

>> A*inv (B)

ans =

0.6126 0.2928

Page 19: Comandos Import Antes y Simbolos en Matrices

-0.0631 -0.4640

>> A/B

ans =

0.6126 0.2928

-0.0631 -0.4640

>> A\B

ans =

-0.7627 3.0847

1.1695 0.2034

>> inv(A)*B

ans =

-0.7627 3.0847

1.1695 0.2034