Está en la página 1de 22

a=5

a =

b=8;
a+b

ans =

13

a-b

ans =

-3

a*b

ans =

40

a/b

ans =

0.6250

a^b

ans =

390625

who

Your variables are:

a ans b

whos
Name Size Bytes Class Attributes

a 1x1 8 double
ans 1x1 8 double
b 1x1 8 double

clc
format long
pi

ans =

3.141592653589793

format short
pi

ans =

3.1416

format long e
pi

ans =

3.141592653589793e+00

format short e
pi

ans =

3.1416e+00

format long eng


pi

ans =

3.14159265358979e+000

format short eng


pi

ans =

3.1416e+000

format bank
pi

ans =

3.14

format hex
pi

ans =

400921fb54442d18

format rat
pi

ans =

355/113

format +
pi

ans =
+

clc
inf

ans =

format short
inf

ans =

Inf

nan

ans =

NaN

realmin

ans =

2.2251e-308

realmax

ans =

1.7977e+308

clc
ceil(pi)

ans =

floor(pi)

ans =

fix(pi)

ans =

round(pi)

ans =

3
sin(pi)

ans =

1.2246e-16

sind(180)

ans =

sinh(pi)

ans =

11.5487

asin(pi/2)

ans =

1.5708 - 1.0232i

asin(1)

ans =

1.5708

ans*180/pi

ans =

90

asinh(1)

ans =

0.8814

abs(-7)

ans =

sign(pi)

ans =

exp
{#Error using <a
href="matlab:matlab.internal.language.introspective.errorDocCallback('exp')"
style="font-weight:bold">exp</a>
Not enough input arguments.
}#
exp(3)

ans =

20.0855

e
{#Undefined function or variable 'e'.
}#
log(2)

ans =

0.6931

log10(2)

ans =

0.3010

log2(2)

ans =

gcd(9,12)

ans =

lcm(9,12)

ans =

36

mod(-12,5)

ans =

rem(12,5)

ans =

sqrt(100)

ans =

10
nthroot(27,3)

ans =

x=3+4i

x =

3.0000 + 4.0000i

y=2-5j

y =

2.0000 - 5.0000i

sqrt(x)

ans =

2.0000 + 1.0000i

nthroot(y,5)
{#Error using <a
href="matlab:matlab.internal.language.introspective.errorDocCallback('nthroot',
'C:\Program Files\MATLAB\R2017a\toolbox\matlab\elfun\nthroot.m', 16)" style="font-
weight:bold">nthroot</a> (<a href="matlab: opentoline('C:\Program
Files\MATLAB\R2017a\toolbox\matlab\elfun\nthroot.m',16,0)">line 16</a>)
Both X and N must be real.
}#
abs(x)

ans =

x/5

ans =

0.6000 + 0.8000i

sign(x)

ans =

0.6000 + 0.8000i

angle(x)

ans =

0.9273

conj(x)

ans =
3.0000 - 4.0000i

imag(x)

ans =

real(x)

ans =

isreal(x)

ans =

<a href="matlab:helpPopup logical" style="font-weight:bold">logical</a>

clc
complex(3,7)

ans =

3.0000 + 7.0000i

x=[3 -7 4 -2 1]

x =

3 -7 4 -2 1

y=[3;-7;4;-2;1]

y =

3
-7
4
-2
1

z=x+2

z =

5 -5 6 0 3

x(2)

ans =

-7

x
x =

3 -7 4 -2 1

x(4)

ans =

-2

x(end)

ans =

z=[2 3 4;2 -1 0;2 7 -3]

z =

2 3 4
2 -1 0
2 7 -3

z(2,3)

ans =

x(2:4)

ans =

-7 4 -2

x(1:2:5)

ans =

3 4 1

z(:,2)

ans =

3
-1
7

z(1,:)

ans =

2 3 4

x([3 5 1])
ans =

4 1 3

A=[3 2 1;7 6 8]

A =

3 2 1
7 6 8

A(2,1)

ans =

A(5)

ans =

A =

3 2 1
7 6 8

A(2,:)

ans =

7 6 8

A(:,2)

ans =

2
6

A(2,2:3)

ans =

6 8

A(1:2,2)

ans =

2
6

A(end [1 3])
A(end [1 3])
#
{#Error: Unbalanced or unexpected parenthesis or bracket.
}#
A(end,[1 3])

ans =

7 8

A =

3 2 1
7 6 8

zeros(5)

ans =

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

zeros(5,3)

ans =

0 0 0
0 0 0
0 0 0
0 0 0
0 0 0

ones(7)

ans =

1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1

ones(5,4)

ans =

1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1

rand(5)
ans =

0.8147 0.0975 0.1576 0.1419 0.6557


0.9058 0.2785 0.9706 0.4218 0.0357
0.1270 0.5469 0.9572 0.9157 0.8491
0.9134 0.9575 0.4854 0.7922 0.9340
0.6324 0.9649 0.8003 0.9595 0.6787

%Distribucion uniforme
rand(3,2)

ans =

0.7577 0.6555
0.7431 0.1712
0.3922 0.7060

randn(5)

ans =

-1.1471 0.3252 -0.2414 -0.1649 0.0774


-1.0689 -0.7549 0.3192 0.6277 -1.2141
-0.8095 1.3703 0.3129 1.0933 -1.1135
-2.9443 -1.7115 -0.8649 1.1093 -0.0068
1.4384 -0.1022 -0.0301 -0.8637 1.5326

%Distribucion normal
randn(2,3)

ans =

-0.7697 -0.2256 -1.0891


0.3714 1.1174 0.0326

eye(4)

ans =

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

eye(4,3)

ans =

1 0 0
0 1 0
0 0 1
0 0 0

hilb(6)

ans =

1.0000 0.5000 0.3333 0.2500 0.2000 0.1667


0.5000 0.3333 0.2500 0.2000 0.1667 0.1429
0.3333 0.2500 0.2000 0.1667 0.1429 0.1250
0.2500 0.2000 0.1667 0.1429 0.1250 0.1111
0.2000 0.1667 0.1429 0.1250 0.1111 0.1000
0.1667 0.1429 0.1250 0.1111 0.1000 0.0909

%Matriz de Hilbert
invhilb(6)

ans =

36 -630 3360 -7560 7560 -2772


-630 14700 -88200 211680 -220500 83160
3360 -88200 564480 -1411200 1512000 -582120
-7560 211680 -1411200 3628800 -3969000 1552320
7560 -220500 1512000 -3969000 4410000 -1746360
-2772 83160 -582120 1552320 -1746360 698544

Z
{#Undefined function or variable 'Z'.
}#
z

z =

2 3 4
2 -1 0
2 7 -3

y =

3
-7
4
-2
1

y=(3;-7;1)
y=(3;-7;1)
#
{#Error: Unbalanced or unexpected parenthesis or bracket.
}#
y=[3;-7;1]

y =

3
-7
1

z\y

ans =

-2.7955
1.4091
1.0909
A=[1 2 3;4 5 6;7 8 9]

A =

1 2 3
4 5 6
7 8 9

B=[A+2]

B =

3 4 5
6 7 8
9 10 11

A+B

ans =

4 6 8
10 12 14
16 18 20

A-B

ans =

-2 -2 -2
-2 -2 -2
-2 -2 -2

A*B

ans =

42 48 54
96 111 126
150 174 198

A.*B

ans =

3 8 15
24 35 48
63 80 99

A/B
[#Warning: Matrix is close to singular or badly scaled. Results may be inaccurate.
RCOND = 2.158767e-18.]#

ans =

2.6190 -2.5714 0.9524


2.9762 -4.2857 2.3095
0.5476 -0.4286 0.8810

%Division de una matriz por la derecha


A./B

ans =

0.3333 0.5000 0.6000


0.6667 0.7143 0.7500
0.7778 0.8000 0.8182

A\B
[#Warning: Matrix is close to singular or badly scaled. Results may be inaccurate.
RCOND = 2.202823e-18.]#

ans =

0 0.2000 0.4000
0 -1.4000 -2.8000
1.0000 2.2000 3.4000

%Division de una matriz por la izquierda


A.\B

ans =

3.0000 2.0000 1.6667


1.5000 1.4000 1.3333
1.2857 1.2500 1.2222

A^2

ans =

30 36 42
66 81 96
102 126 150

A.^2

ans =

1 4 9
16 25 36
49 64 81

A*A

ans =

30 36 42
66 81 96
102 126 150

A.*A

ans =

1 4 9
16 25 36
49 64 81
A.^B

ans =

1.0e+10 *

0.0000 0.0000 0.0000


0.0000 0.0000 0.0002
0.0040 0.1074 3.1381

A'

ans =

1 4 7
2 5 8
3 6 9

A.'

ans =

1 4 7
2 5 8
3 6 9

A' %transposicion compleja conjugada

ans =

1 4 7
2 5 8
3 6 9

A.' %transposicion de matrices

ans =

1 4 7
2 5 8
3 6 9

x=[1 2 3]

x =

1 2 3

y=x+2

y =

3 4 5

dot(x,y)

ans =

26
%dot: producto punto
cross(x,y)

ans =

-2 4 -2

%cross: producto vectorial


clc
A

A =

1 2 3
4 5 6
7 8 9

cond(A)

ans =

5.0523e+16

%cond:numero de condicion de la matriz


det(A)

ans =

-9.5162e-16

diag(x)

ans =

1 0 0
0 2 0
0 0 3

%diag:creo una matriz a partir de un vector, colocando los terminos en la diagonal


principal de mi matriz
diag(A)

ans =

1
5
9

%diag:para matrices, m devuelve los valores de mi matriz principal


%diag:para matrices, m devuelve los valores de mi diagonal principal
eig(A)

ans =

16.1168
-1.1168
-0.0000
%eig:valores propios de la matriz
inv(A)
[#Warning: Matrix is close to singular or badly scaled. Results may be inaccurate.
RCOND = 2.202823e-18.]#

ans =

1.0e+16 *

0.3153 -0.6305 0.3153


-0.6305 1.2610 -0.6305
0.3153 -0.6305 0.3153

%inv:inversa de la matriz A
length(A)

ans =

norm(A)

ans =

16.8481

norm(A,2)

ans =

16.8481

%Norma enesima de una matriz


norm(A,5)
{#Error using <a
href="matlab:matlab.internal.language.introspective.errorDocCallback('norm')"
style="font-weight:bold">norm</a>
The only matrix norms available are 1, 2, inf, and 'fro'.
}#
norm(A,fro)
{#Undefined function or variable 'fro'.
}#
norm(A,for)
norm(A,for)
#
{#Error: Illegal use of reserved keyword "for".
}#
norm(A,'fro')

ans =

16.8819

%Norma 'fro'
normest(A)

ans =

16.8481
%normest:estimacion de la norma 2
null(A)

ans =

-0.4082
0.8165
-0.4082

%null:espacio nulo de la matriz A


orth(A)

ans =

-0.2148 0.8872
-0.5206 0.2496
-0.8263 -0.3879

%orth:matriz ortogonal
pinv(A)

ans =

-0.6389 -0.1667 0.3056


-0.0556 0.0000 0.0556
0.5278 0.1667 -0.1944

%pinv:matriz pseudo inversa


poly(A)

ans =

1.0000 -15.0000 -18.0000 -0.0000

%poly:polinomio caracteristico
rank(A)

ans =

%rank:rango de la matriz
rref(A)

ans =

1 0 -1
0 1 2
0 0 0

%rref:reduccion por el metodo de Gauss


size(A)

ans =

3 3

%size:dimension de la matriz fila x columna


trace(A) %traza

ans =

15

tril(A) %matriz triangular inferior

ans =

1 0 0
4 5 0
7 8 9

triu(A)

ans =

1 2 3
0 5 6
0 0 9

%triu:matriz triangular superior


find(A)

ans =

1
2
3
4
5
6
7
8
9

%find:indices de la matriz donde los valores no es diferente de 0 (posicion)


A

A =

1 2 3
4 5 6
7 8 9

fliplr(A) %intercambia la matriz de izquierda a derecha (columnas)

ans =

3 2 1
6 5 4
9 8 7

flipud(A) %intercambia la matriz de arriba hacia abajo (filas)

ans =

7 8 9
4 5 6
1 2 3

reshape(A,3,3) %crea una matriz a partir de la matriz base

ans =

1 2 3
4 5 6
7 8 9

A =

1 2 3
4 5 6
7 8 9

rot90(A) %roto 90 gravos en sentido antihorario

ans =

3 6 9
2 5 8
1 4 7

rot90(A,2) %roto 90 grados en sentido antihorario 2 veces

ans =

9 8 7
6 5 4
3 2 1

expm(A)

ans =

1.0e+06 *

1.1189 1.3748 1.6307


2.5339 3.1134 3.6929
3.9489 4.8520 5.7552

%expm:eleva 'e' con cada uno de los terminos de la matriz


logm(A)
[#Warning: Principal matrix logarithm is not defined for A with nonpositive real
eigenvalues. A non-principal matrix logarithm is
returned.]#
[#> In <a
href="matlab:matlab.internal.language.introspective.errorDocCallback('logm',
'C:\Program Files\MATLAB\R2017a\toolbox\matlab\matfun\logm.m', 78)" style="font-
weight:bold">logm</a> (<a href="matlab: opentoline('C:\Program
Files\MATLAB\R2017a\toolbox\matlab\matfun\logm.m',78,0)">line 78</a>)]#

ans =

-5.3694 + 2.7896i 11.9253 - 0.4325i -5.3431 - 0.5129i


12.2351 - 0.7970i -22.1731 + 2.1623i 12.5449 - 1.1616i
-4.7235 - 1.2421i 12.8547 - 1.5262i -4.1303 + 1.3313i

sqrtm(A) %raiz de todos los elementos de la matriz

ans =

0.4498 + 0.7623i 0.5526 + 0.2068i 0.6555 - 0.3487i


1.0185 + 0.0842i 1.2515 + 0.0228i 1.4844 - 0.0385i
1.5873 - 0.5940i 1.9503 - 0.1611i 2.3134 + 0.2717i

funm(A,@sin) %saco una funcion cualquiera a todos los elementos de la matriz

ans =

-0.6928 -0.2306 0.2316


-0.1724 -0.1434 -0.1143
0.3479 -0.0561 -0.4602

[VE,VA]=eig(A)

VE =

-0.2320 -0.7858 0.4082


-0.5253 -0.0868 -0.8165
-0.8187 0.6123 0.4082

VA =

16.1168 0 0
0 -1.1168 0
0 0 -0.0000

%[VE,VA]=eig(A): valores y vectores propios


[L,U]=lu(A)

L =

0.1429 1.0000 0
0.5714 0.5000 1.0000
1.0000 0 0

U =

7.0000 8.0000 9.0000


0 0.8571 1.7143
0 0 -0.0000

[Q,R]=qr(A)%factorizacion QR

Q =

-0.1231 0.9045 0.4082


-0.4924 0.3015 -0.8165
-0.8616 -0.3015 0.4082
R =

-8.1240 -9.6011 -11.0782


0 0.9045 1.8091
0 0 -0.0000

A=zeros(2,3)

A =

0 0 0
0 0 0

B=ones(2,3)

B =

1 1 1
1 1 1

cat(1,A,B) %concatenar las matrices una debajo de otra

ans =

0 0 0
0 0 0
1 1 1
1 1 1

cat(2,A,B) %concatenar las matrices una a lado de la otra

ans =

0 0 0 1 1 1
0 0 0 1 1 1

cat(3,A,B)

ans(:,:,1) =

0 0 0
0 0 0

ans(:,:,2) =

1 1 1
1 1 1

clc
diary off