Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Practicas 0809
Practicas 0809
>> d = 2 + sqrt(4)i;
el programa nos arrojará el siguiente error y nos señalará con una barra vertical el
motivo del mismo
??? d = 2 + sqrt(4)i
|
Missing operator, comma, or semi-colon.
Esto nos está diciendo que en lugar del + debe ir una coma o un punto y coma, esto
es porque Matlab no pudo interpretar el segundo sumando, sqrt(4)i. En cambio si
ingresamos
>> d = 2 + sqrt(4)*i
>> a = 1 + i;
>> b = 1;
>> c = i;
Las funciones real e imag retornan la parte real y la parte imaginaria de un complejo
respectivamente:
>> d = 3 + sqrt(2)*i;
d = 3.0000 +
1.4142i
>> real(d)
ans = 3
>> imag(d)
ans = 1.4142
>> abs(a)
ans = 1.4142
>>
abs(b)
ans = 1
>> abs(c)
ans = 1
>> angle(a)
ans = 0.7854
>> atan(imag(a)/real(a))
ans = 0.7854
>> rad2deg(ans)
ans = 45
>> d = -sqrt(3) + i
d = -1.7321 + 1.0000i
pol2cart
Transform polar or cylindrical coordinates to Cartesian
Syntax
[X,Y] = pol2cart(THETA,RHO)
[X,Y,Z] = pol2cart(THETA,RHO,Z)
Description
Algorithm
The mapping from polar and cylindrical coordinates to Cartesian coordinates is:
See Also
plotyypolar
MATLAB Function Reference
cart2pol
Transform Cartesian coordinates to polar or cylindrical
Syntax
[THETA,RHO,Z] = cart2pol(X,Y,Z)
[THETA,RHO] = cart2pol(X,Y)
Description
Algorithm
The mapping from two-dimensional Cartesian coordinates to polar coordinates, and from
three-dimensional Cartesian coordinates to cylindrical coordinates is:
See Also
capturecart2sph
Capítulo 3: Operaciones con matrices y vectores página 23
A partir de este momento la matriz A está disponible para hacer cualquier tipo de operación con ella
(además de valores numéricos, en la definición de una matriz o vector se pueden utilizar expresio-
nes y funciones matemáticas). Por ejemplo, una sencilla operación con A es hallar su matriz tras-
puesta. En MATLAB el apóstrofo (') es el símbolo de transposición matricial. Para calcular A'
(traspuesta de A) basta teclear lo siguiente (se añade a continuación la respuesta del programa):
>> A'
ans =
1 4 7
2 5 8
3 6 9
Como el resultado de la operación no ha sido asignado a ninguna otra matriz, MATLAB utiliza un
nombre de variable por defecto (ans, de answer), que contiene el resultado de la última operación.
La variable ans puede ser utilizada como operando en la siguiente expresión que se introduzca.
También podría haberse asignado el resultado a otra matriz llamada B:
6
Aunque en MATLAB las matrices se introducen por filas, se almacenan por columnas, lo cual tiene su importancia
como se verá más adelante.
Aprenda Matlab 7.0 como si estuviera en Primero página 24
>> B=A'
B= 1 4 7
2 5 8
3 6 9
Ahora ya están definidas las matrices A y B, y es posible seguir operando con ellas. Por ejemplo, se
puede hacer el producto B*A (deberá resultar una matriz simétrica):
>> B*A
ans =
66 78 90
78 93 108
90 108 126
En MATLAB se accede a los elementos de un vector poniendo el índice entre paréntesis (por ejem-
plo x(3) ó x(i)). Los elementos de las matrices se acceden poniendo los dos índices entre paréntesis,
separados por una coma (por ejemplo A(1,2) ó A(i,j)). Las matrices se almacenan por columnas
(aunque se introduzcan por filas, como se ha dicho antes), y teniendo en cuenta esto puede acceder-
se a cualquier elemento de una matriz con un sólo subíndice. Por ejemplo, si A es una matriz
(3×3) se obtiene el mismo valor escribiendo A(1,2) que escribiendo A(4).
Invertir una matriz es casi tan fácil como trasponerla. A continuación se va a definir una nueva ma-
triz A -no singular- en la forma:
>> A=[1 4 -3; 2 1 5; -2 5 3]
A= 1 4 -3
2 1 5
-2 5 3
Ahora se va a calcular la inversa de A y el resultado se asignará a B. Para ello basta hacer uso de la
función inv( ) (la precisión o número de cifras con que se muestra el resultado se puede cambiar con
el menú File/Preferences/General):
B=inv(A)
B = 0.1803 0.2213 -0.1885
0.1311 0.0246 0.0902
-0.0984 0.1066 0.0574
Por el contrario, si los números están separados por intros o puntos y coma (;) se obtendrá un vec-
tor columna:
Capítulo 3: Operaciones con matrices y vectores página 25
MATLAB tiene en cuenta la diferencia entre vectores fila y vectores columna. Por ejemplo, si se
intenta sumar los vectores x e y se obtendrá el siguiente mensaje de error:
>> x+y
??? Error using ==> +
Matrix dimensions must agree.
7
En términos de C++ se podría decir que son operadores sobrecargados, es decir, con varios significados distintos
dependiendo del contexto, es decir, de sus operandos.
Aprenda Matlab 7.0 como si estuviera en Primero página 26
>> A=[1 2; 3 4]
A= 1 2
3 4
>> A*2
ans =
2 4
6 8
>> A-4
ans =
-3 -2
-1 0
MATLAB utiliza el operador de división / para dividir por un escalar todos los elementos de una
matriz o un vector. Esto no constituye ninguna sorpresa. Sin embargo, el uso que se describe a con-
tinuación sí requiere más atención.
que es la solución obtenida dando valor cero a la variable independiente x(1). Por otra parte, en el
caso de un sistema de ecuaciones redundante (o sobre-determinado) el resultado de MATLAB es el
punto más “cercano” -en el sentido de mínima norma del error- a las ecuaciones dadas (aunque no
8
En inglés, MATLAB denomina mldivide a este operador. Para más información, teclear help mldivide.
Capítulo 3: Operaciones con matrices y vectores página 27
cumpla exactamente ninguna de ellas). Véase el siguiente ejemplo de tres ecuaciones formadas por
una recta que no pasa por el origen y los dos ejes de coordenadas:
>> A=[1 2; 1 0; 0 1], b=[2 0 0]'
A= 1 2
1 0
b= 0 1
2
0
0
>> x=A\b, resto=A*x-b
x = 0.3333
0.6667
resto =
-0.3333
0.3333
0.6667
Si la matriz es singular o está muy mal escalada, el operador \ da un aviso (warning), pero propor-
ciona una solución.
La “inteligencia” del operador barra invertida \ tiene un coste: MATLAB debe de emplear cierto
tiempo en determinar las características de la matriz: triangular, simétrica, etc. Si el usuario conoce
perfectamente y con seguridad las características de la matriz del sistema, lo mejor es utilizar la
función linsolve (ver sección 4.5.4, en la página 46), que no realiza ninguna comprobación y puede
obtener la máxima eficiencia.
Aunque no es una forma demasiado habitual, también se puede escribir un sistema de ecuaciones
lineales en la forma correspondiente a la traspuesta de la ecuación (1):
yB = c (3)
donde y y c son vectores fila (c conocido). Si la matriz B es cuadrada e invertible, la solución de
este sistema se puede escribir en las formas siguientes:
y = c*inv(B) (4a)
y = c/B (4b)
En este caso, el operador división-derecha por una matriz (/) equivale a postmultiplicar por la in-
versa de la matriz. Si se traspone la ecuación (3) y se halla la solución aplicando el operador divi-
sión-izquierda se obtiene:
y' = (B')\c' (5)
Comparando las expresiones (4b) y (5) se obtiene la relación entre los operadores división-izquierda
y división-derecha (MATLAB sólo tiene implementado el operador división-izquierda):
c/B = ((B')\c')' (6)
EXAMPLE 4.2 Obtain the current in each branch of the network shown in Fig. 4-2 (same as Fig. 4-1) using the
mesh current method.
Fig. 4-2
The currents I1 and I2 are chosen as shown on the circuit diagram. Applying KVL around the left loop,
starting at point α,
Rearranging terms,
Solving (4) and (5) simultaneously results in I1 ¼ 2 A and I2 ¼ 1 A. The current in the center branch, shown dotted,
is I1 — I2 ¼ 1 A. In Example 4.1 this was branch current I3.
The currents do not have to be restricted to the windows in order to result in a valid set of
simultaneous equations, although that is the usual case with the mesh current method. For example,
see Problem 4.6, where each of the currents passes through the source. In that problem they are called
loop currents. The applicable rule is that each element in the network must have a current or a
combination of currents and no two elements in different branches can be assigned the same current
or the same combination of currents.
EXAMPLE 4.3 When KVL is applied to the three-mesh network of Fig. 4-3, the following three equations are
obtained:
CHAP. 4] ANALYSIS METHODS 39
ðRA þ RB ÞI1 — RB I2 ¼ Va
—RB I1 þ ðRB þ RC þ RD ÞI2 — RD I3 ¼ 0
—RD I2 þ ðRD þ RE ÞI3 ¼ —Vb
Fig. 4-3
The matrix equation arising from the mesh current method may be solved by various techniques.
One of these, the method of determinants (Cramer’s rule), will be presented here. It should be stated,
however, that other techniques are far more efficient for large networks.
EXAMPLE 4.4 Solve matrix equation (6) of Example 4.3 by the method of determinants.
The unknown current I1 is obtained as the ratio of two determinants. The denominator determinant has the
elements of resistance matrix. This may be referred to as the determinant of the coefficients and given the symbol
OR. The numerator determinant has the same elements as OR except in the first column, where the elements of the
voltage matrix replace those of the determinant of the coefficients. Thus,
,
V1 R12 R13 R11 R12 R13
. . . V R R
1 . 1 12 13 .
I1 ¼ V2 R22 R23 R21 R22 R23 ÷ . V2 R22 R23 .
.V R O R. V R R .
. 3 32 R33 . ..R31 R32 R33 .
3 32 33
. .
48 ANALYSIS METHODS [CHAP. 4
Fig. 4-17
Fig. 4-18
60 ¼ 7I1 þ 12ðI1 — I2 Þ
0 ¼ 12ðI2 — I1 Þ þ 6ðI2 — I3 Þ
0 ¼ 6ðI3 — I 2 Þþ 12I3
19I1 — 12I2 ¼ 2 32
60 2 3
19 —12 0 I1 60
3
. 60 —12 0.
. 19 —12 0.
I1 ¼ 0 18 —6 ÷ —12 18 —6 ¼ 17 280 ÷ 2880 ¼ 6A
. 0 —6 18 . .. 0 —6 18.
. .
CHAP. 9] SINUSOIDAL STEADY-STATE CIRCUIT ANALYSIS 199
2 32 3
Z11 Z12 Z13 I1
2 13
4 Z21 Z22 Z23 54 I2 5 ¼ 4 V
V2 5
Z31 Z32 Z33 I3 V3
for the unknown mesh currents I1; I2; I3. Here, Z11 ÷ ZA þ ZB, the self-impedance of mesh 1, is the sum
of all impedances through which I1 passes. Similarly, Z÷ 22 ZB þZC Zþ D and Z33 ZD ÷ZE are the self-
impedances of meshes 2 and 3. þ
Fig. 9-12
where a summand takes the plus sign if the two currents pass through the impedance in the same
direction, and takes the minus sign in the opposite case. It follows that, invariably, Z12 ¼ Z21. In Fig.
9-12, I1 and I2 thread ZB in opposite directions, whence
Z12 ¼ Z21 ¼ —ZB
Similarly,
where a summand takes the plus sign if the voltage drives in the direction of Ik, and takes the minus sign
in the opposite case. For the network of Fig. 9-12,
V1 ¼ þVa V2 ¼ 0 V3 ¼ —Vb
Instead of using the meshes, or ‘‘windows’’ of the (planar) network, it is sometimes expedient to
choose an appropriate set of loops, each containing one or more meshes in its interior. It is easy to see
that two loop currents might have the same direction in one impedance and opposite directions in
another. Nevertheless, the preceding rules for writing the Z-matrix and the V-column have been
formulated in such a way as to apply either to meshes or to loops. These rules are, of course, identical
to those used in Section 4.3 to write the R-matrix and V-column.
EXAMPLE 9.6 Suppose that the phasor voltage across ZB, with polarity as indicated in Fig. 9-13 is sought.
Choosing meshes as in Fig. 9-12 would entail solving for both I1 and I2, then obtaining the voltage as VB ¼ ðI2 —
I1ÞZB. In Fig. 9-13 three loops (two of which are meshes) are chosen so as to make I1 the only current in ZB.
Furthermore, the direction of I1 is chosen such that VB ¼ I1ZB. Setting up the matrix equation:
208 SINUSOIDAL STEADY-STATE CIRCUIT ANALYSIS [CHAP. 9
9.18 Obtain the voltage Vx in the network of Fig. 9-28, using the mesh current method.
Fig. 9-28
One choice of mesh currents is shown on the circuit diagram, with I3 passing through the 10-K resistor
in a direction such that Vx ¼ I3ð10Þ (V). The matrix equation can be written by inspection:
2 2 3
7 þ j3 j5 5 32 1 10 0 8
3 I 6 7
4 j5 12 þ j3 —ð2 — j2Þ 54 I2 5 ¼ 4 5 308 5
5 —ð2 — j2Þ 17 — j2 I3 0
Solving by determinants,
. 7 þ j3 j5 10 08 .
8
. .
. j5 12 þ j3 5 30 .
667:96 —169:098
I3 ¼ . .¼ ¼ 0:435 —194:158 A
5 —2 þ j2 0
7 þ j3 j5 5 1534:5 25:068
.
.
j5 12 þ j3 —2 þ
. j2
j2 5 —19—2
and Vx ¼ I3 ð10Þ ¼ 4:35
þ j2 17 —
4:158 V.
9.19 In the netwrok of Fig. 9-29, determine the voltage V which results in a zero current through
the 2 þ j3 K impedance.
Fig. 9-29
Página 1
Cursor de Excel
En el tema anterior se estudió que la energía necesaria para mover una carga entre dos
puntos de diferente potencial es W qV , de donde salía la expresión general de la potencia
eléctrica
dW dq
P dt V dt VI
P(t)
V sin(t)I sin(t ) V cos cos(2t ) cos cos(2t )
V V
I I I
max max max max max
max max max
2 2 2
cos(2t )dt 0
0
Representa la energía que se almacena temporalmente (en forma de carga eléctrica en los
condensadores o en forma magnética en las bobinas) y es devuelta al sistema.
El valor promedio de la potencia, vendrá dado por tanto por el primer sumando, que puede
escribirse en función de los valores eficaces como
Vmax
P I max
cos eV e cos
22
I
Electrotecnia. 2º ITOP. Curso 2007/08 Tema 3 - Pág.
10
Página 3
Copiar la fórmula hacia abajo estirando de la esquina con el cursor de copiar fórmula
Elegir gráfico ‘XY Dispersión’ con líneas suavizadas sin puntos, y pulsar ‘Finalizar’
1,5
0,5
VI
0 P
0
-0,5 50 100 150 200 250 300 350 400
-1
-1,5
Página 6
90º Bobina
-90º Condensador
0º Resistencia
Paso 11. Corregir las fórmulas de Tensión e Intensidad para cambiar el valor máximo de
ambos, que en origen es 1, a Vmax=3 e Imax=2.
Página 7
6,000
5,000
4,000
3,000
2,000
1,000 I
0,000
P
0 5 100 150 200 250 300 350 40
-1,000
0 0
-2,000
-3,000
-4,000