Beruflich Dokumente
Kultur Dokumente
A=
2 3
4 5
>> b11=input ('ingrese el valor de b11:');b12=input('ingrese el valor
deb12:');b21=input('ingrese el valor de b21:');b22=input('ingrese el valor de
b22:');B=[b11 b12;b21 b22]
ingrese el valor de b11:6
ingrese el valor de b12:7
ingrese el valor de b21:8
ingrese el valor de b22:9
B=
6 7
8 9
>> C=A+B
C=
8 10
12 14
Ejercicio. Hacer un programa en Matlab para ingresar datos a una matriz y realizar la
𝐴+𝐵−𝐶
siguiente operación |2𝐴+𝐵−2𝐶|
1 −2 3 4 3 2 4 8 9
Donde 𝐴 = [−1 2 3] ; 𝐵 = [ 6 5 2] ; 𝐶 = [−2 4 6]
6 5 4 −1 2 7 −1 7 8
Solución
>> a1=input('ingrese el valor de a1:');a2=input('ingrese el valor de
a2:');a3=input('ingrese el valor de a3:');a4=input('ingrese el valor de
a4:');a5=input('ingrese el valor de a5:');a6=input('ingrese el valor de
a6:');a7=input('ingrese el valor de a7:');a8=input('ingrese el valor de
a8:');a9=input('ingrese el valor de a9:');A=[a1 a2 a3;a4 a5 a6;a7 a8 a9]
ingrese el valor de a1:1
ingrese el valor de a2:-2
ingrese el valor de a3:3
ingrese el valor de a4:-1
ingrese el valor de a5:2
ingrese el valor de a6:3
ingrese el valor de a7:6
ingrese el valor de a8:5
ingrese el valor de a9:4
A=
1 -2 3
-1 2 3
6 5 4
>> b1=input('ingrese el valor de b1:');b2=input('ingrese el valor de
b2:');b3=input('ingrese el valor de b3:');b4=input('ingrese el valor de
b4:');b5=input('ingrese el valor de b5:');b6=input('ingrese el valor de
b6:');b7=input('ingrese el valor de b7:');b8=input('ingrese el valor de
b8:');b9=input('ingrese el valor de b9:');B=[b1 b2 b3;b4 b5 b6;b7 b8 b9]
ingrese el valor de b1:4
ingrese el valor de b2:3
ingrese el valor de b3:2
ingrese el valor de b4:6
ingrese el valor de b5:5
ingrese el valor de b6:2
ingrese el valor de b7:-1
ingrese el valor de b8:2
ingrese el valor de b9:7
B=
4 3 2
6 5 2
-1 2 7
>> c1=input('ingrese el valor de c1:');c2=input('ingrese el valor de
c2:');c3=input('ingrese el valor de c3:');c4=input('ingrese el valor de
c4:');c5=input('ingrese el valor de c5:');c6=input('ingrese el valor de
c6:');c7=input('ingrese el valor de c7:');c8=input('ingrese el valor de
c8:');c9=input('ingrese el valor de c9:');C=[c1 c2 c3;c4 c5 c6;c7 c8 c9]
ingrese el valor de c1:4
ingrese el valor de c2:8
ingrese el valor de c3:9
ingrese el valor de c4:-2
ingrese el valor de c5:4
ingrese el valor de c6:6
ingrese el valor de c7:-1
ingrese el valor de c8:7
ingrese el valor de c9:8
C=
4 8 9
-2 4 6
-1 7 8
>> D=A+B-C
D=
1 -7 -4
7 3 -1
6 0 3
>> E=2*A+B-2*C
E=
-2 -17 -10
8 1 -4
13 -2 -1
>> F=D./E
F=
>> det(F)
ans =
5.0745
3.2 GENERACIÓN DE VECTORES
Formatos útiles para definir vectores.
Un vector de n elementos se puede representar de la siguiente manera.
𝑉 = [𝑣1 ; 𝑣2 ; … ; 𝑣𝑛 ]
Forma general
Variable = vector arbitrario
>> V2=[24:30]
V2 =
24 25 26 27 28 29 30
>> V3=[8:14]
V3 =
8 9 10 11 12 13 14
>> V=V1.*V2-V3
V=
88 116 146 178 212 248 286
b) 2𝑉1∗𝑉2∗𝑉3
>> 2.^(V1.*V2.*V3)
ans =
1.0e+231 *
1.5525 Inf Inf Inf Inf Inf Inf
>> V5=[4:3:17]
V5 =
4 7 10 13 16
>> V6=[10:-2:5]
V6 =
10 8 6
Ejercicio. Calcular en Matlab las siguientes operaciones.
a) 𝑉1 + 𝑉2 + 𝑉3
>> V1=[4:2:12]
V1 =
4 6 8 10 12
>> V2=[10:3:23]
V2 =
10 13 16 19 22
>> V3=[22:-4:5]
V3 =
22 18 14 10 6
>> V=V1+V2-V3
V=
-8 1 10 19 28
b) 𝑉1 ∗ 𝑉2 + 𝑉3𝑉1+𝑉2∗𝑉3
>> U=(V1.*V2+V3).^(V1+V2.*V3)
U=
Inf Inf Inf Inf Inf
>> V6=linspace(0,10,5)
V6 =
0 2.5000 5.0000 7.5000 10.0000
V1 =
12 14 16 18 20
>> V2=linspace(6,12,5)
V2 =
>> V3=linspace(22,30,5)
V3 =
22 24 26 28 30
>> U=V1+V2-V3
U=
>> W=V1.*V2+V3
W=
>> H=U/W
H=
-0.0013
>> H=U./W
H=
Ejemplo: Ejercicio:
3.2.5 Concatenación de vectores y matrices
Ejemplo
Ejercicio Concatenas las siguientes matrices