```python
import numpy as np
#from sympy import *
from matplotlib import pyplot as plt
from scipy import signal
import control
```

# Trabajo practico N°1

## Ejercicio 1

i) $$\begin{equation} \frac{Y(s)}{X(s)} = \frac{125}{s^2+10s+25}\end{equation}$$

#### Transferencia

$$\begin{equation} H(s) = \frac{125}{(s+5)^2}\end{equation}$$

#### Ecuacion diferencial

$$\begin{equation} \frac{d^2y(t)}{dt^2} + 10\frac{dy(t)}{dt} + 25y(t) = 125x(t)\end{equation}$$

#### Polos y ceros


```python
num1 = np.array([0, 0, 125])
den1 = np.array([1, 10, 25])

tf1 = control.tf(num1, den1)
control.pzmap(tf1);
```

#### Respuesta al escalon


```python
t, y = control.step_response(tf1)
#plt.plot(t, y, label= "time");
fig, ax = plt.subplots()
ax.plot(t, y)

ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

##### Analiticamente llegue a la siguiente expresion

$$\begin{equation}y(t) = 5[1-e^{-5t}(1+5t)]u(t)\end{equation}$$

##### Vamos a graficarla


```python
u = np.ones(t.size)
y = 5 * (1 - np.exp(-5 * t) * (1 + 5 * t)) * u

fig, ax = plt.subplots()
ax.plot(t, y)
ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

ii) $$\begin{equation} \frac{Y(s)}{X(s)} = \frac{10}{s^2+2s+5}\end{equation}$$

#### Transferencia

$$\begin{equation} H(s) = \frac{10}{s^2+2s+5}\end{equation}$$

#### Ecuacion diferencial

$$\begin{equation} \frac{d^2y(t)}{dt^2} + 2\frac{dy(t)}{dt} + 5y(t) = 10x(t)\end{equation}$$

#### Polos y ceros


```python
num = np.array([0, 0, 10])
den = np.array([1, 2, 5])

tf = control.tf(num, den)
control.pzmap(tf);
```

#### Respuesta al escalon


```python
t, y = control.step_response(tf)
#plt.plot(t, y, label= "time");
fig, ax = plt.subplots()
ax.plot(t, y)

ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

##### Analiticamente llegue a la siguiente expresion

$$\begin{equation}y(t) = 2[1-(cos(2t)+\frac{1}{2}sin(2t)) e^{-t}]u(t)\end{equation}$$

##### Vamos a graficarla


```python
u = np.ones(t.size)
y = 2 * (1 - (np.cos(2*t)+0.5*np.sin(2*t))*np.exp(-t))*u

fig, ax = plt.subplots()
ax.plot(t, y)
ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

iii) $$\begin{equation} \frac{Y(s)}{X(s)} = \frac{60}{s^3+5s^2+16s+30}\end{equation}$$

#### Transferencia

$$\begin{equation} H(s) = \frac{60}{(s+3)(s^2+2s+10)}\end{equation}$$

#### Ecuacion diferencial

$$\begin{equation} \frac{d^3y(t)}{dt^3} + 5\frac{d^2y(t)}{dt^2} + 16\frac{dy(t)}{dt} + 30y(t) = 60x(t)\end{equation}$$

#### Polos y ceros


```python
num1 = np.array([0, 0, 0, 60])
den1 = np.array([1, 5, 16, 30])

tf1 = control.tf(num1, den1)
control.pzmap(tf1);
```

#### Respuesta al escalon


```python
t, y = control.step_response(tf1)
#plt.plot(t, y, label= "time");
fig, ax = plt.subplots()
ax.plot(t, y)

ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

##### Analiticamente llegue a la siguiente expresion

$$\begin{equation}y(t) = 2[1-\frac{1}{13}(10e^{-2t}+3cos(3t)+11sen(3t))e^{-t}]u(t)\end{equation}$$

##### Vamos a graficarla


```python
u = np.ones(t.size)
y = 2*(1 - (10*np.exp(-2*t) + 3*np.cos(3*t) + 11*np.sin(3*t))*np.exp(-t)/13)*u

fig, ax = plt.subplots()
ax.plot(t, y)
ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

iv) $$\begin{equation} \frac{Y(s)}{X(s)} = \frac{3s^2+18s+24}{s^2+4s+3}\end{equation}$$

#### Transferencia

$$\begin{equation} H(s) = 3\frac{(s+2)(s+4)}{(s+1)(s+3)}\end{equation}$$

#### Ecuacion diferencial

$$\begin{equation} \frac{d^2y(t)}{dt^2} + 4\frac{dy(t)}{dt} + 3y(t) = 3\frac{d^2x(t)}{dt^2} + 18\frac{dx(t)}{dt} + 24x(t)\end{equation}$$

#### Polos y ceros


```python
num1 = 3 * np.array([1, 6, 8])
den1 = np.array([1, 4, 3])

tf1 = control.tf(num1, den1)
control.pzmap(tf1);
```

#### Respuesta al escalon


```python
t, y = control.step_response(tf1)
#plt.plot(t, y, label= "time");
fig, ax = plt.subplots()
ax.plot(t, y)

ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

##### Analiticamente llegue a la siguiente expresion

$$\begin{equation}y(t) = [8-\frac{1}{2}(9 + e^{-2t})e^{-t}]u(t)\end{equation}$$

##### Vamos a graficarla


```python
u = np.ones(t.size)
y = (8 - 0.5 * (9 + np.exp(-2*t))*np.exp(-t)) * u

fig, ax = plt.subplots()
ax.plot(t, y)
ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

v) $$\begin{equation} \frac{d^2y(t)}{dt^2} + 4y(t) = 8x(t)\end{equation}$$

#### Transferencia

$$\begin{equation} H(s) = \frac{8}{s^2+4}\end{equation}$$

#### Ecuacion diferencial

$$\begin{equation} \frac{d^2y(t)}{dt^2} + 4y(t) = 8x(t)\end{equation}$$

#### Polos y ceros


```python
num1 = 8 * np.array([0, 0, 1])
den1 = np.array([1, 0, 4])

tf1 = control.tf(num1, den1)
control.pzmap(tf1);
```

#### Respuesta al escalon


```python
t, y = control.step_response(tf1)
#plt.plot(t, y, label= "time");
fig, ax = plt.subplots()
ax.plot(t, y)

ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

##### Analiticamente llegue a la siguiente expresion

$$\begin{equation}y(t) = 2(1-cos(2t))u(t)\end{equation}$$

##### Vamos a graficarla


```python
u = np.ones(t.size)
y = 2 * (1 - np.cos(2 * t)) * u

fig, ax = plt.subplots()
ax.plot(t, y)
ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

vi)$$\begin{equation} y(t) = 8x(t) + 6\int_0^t x(\tau)d\tau + 2 \frac{dx(t)}{dt}\end{equation}$$

#### Transferencia

$$\begin{equation} H(s) = 2\frac{s^2+4s+3}{s}=2\frac{(s+1)(s+3)}{s}\end{equation}$$

#### Ecuacion diferencial

$$\begin{equation} \frac{dy(t)}{dt} = 2\frac{d^2x(t)}{dt^2} + 8\frac{dx(t)}{dt} + 6x(t)\end{equation}$$

#### El problema es que el sistema tiene mas ceros que polos por lo cual no es realizable

vii) $$\begin{equation} \frac{dy(t)}{dt} + y(t) = 2x(t-2)\end{equation}$$

#### Transferencia

$$\begin{equation} H(s) = 2\frac{1}{s+1}e^{-2s}\end{equation}$$

#### Ecuacion diferencial

$$\begin{equation} \frac{dy(t)}{dt} + y(t) = 2x(t-2)\end{equation}$$

#### Polos y ceros


```python
num1 = 2 * np.array([0, 1])
den1 = np.array([1, 1])

tf1 = control.tf(num1, den1)
control.pzmap(tf1);
```

#### Respuesta al escalon


```python
t, y = control.step_response(tf1)
#plt.plot(t, y, label= "time");
fig, ax = plt.subplots()
ax.plot(t, y)

ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

##### Analiticamente llegue a la siguiente expresion

$$\begin{equation}y(t) = 2[1-e^{-(t-2)}]u(t-2)\end{equation}$$

##### Vamos a graficarla


```python
u = np.ones(t.size)
y = 2 * (1 - np.exp(-(t))) * u

fig, ax = plt.subplots()
ax.plot(t, y)
ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

viii) $$\begin{equation} 2\frac{dy(t)}{dt} - 2y(t) = 6x(t)\end{equation}$$

#### Transferencia

$$\begin{equation} H(s) = 3\frac{1}{s-1}\end{equation}$$

#### Ecuacion diferencial

$$\begin{equation} \frac{dy(t)}{dt} - y(t) = 3x(t)\end{equation}$$

#### Polos y ceros


```python
num1 = 3 * np.array([0, 1])
den1 = np.array([1, -1])

tf1 = control.tf(num1, den1)
control.pzmap(tf1);
```

#### Respuesta al escalon


```python
t, y = control.step_response(tf1)
#plt.plot(t, y, label= "time");
fig, ax = plt.subplots()
ax.plot(t, y)

ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

##### Analiticamente llegue a la siguiente expresion

$$\begin{equation}y(t) = 3[e^{t}-1]u(t)\end{equation}$$

##### Vamos a graficarla


```python
u = np.ones(t.size)
y = 3* (np.exp(t) - 1 ) * u

fig, ax = plt.subplots()
ax.plot(t, y)
ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

ix)

#### Transferencia

$$\begin{equation} H(s) = \frac{60}{(s+1)(s+2)(s+3)}=\frac{60}{s^3+6s^2+11s+6}\end{equation}$$

#### Ecuacion diferencial

$$\begin{equation} \frac{d^3y(t)}{dt^3} + 6\frac{d^2y(t)}{dt^2} + 11\frac{dy(t)}{dt} + 6y(t) = 60x(t) \end{equation}$$

#### Polos y ceros


```python
num = np.array([0, 0, 0, 60])
den = np.array([1, 6, 11, 6])

tf = control.tf(num, den)
control.pzmap(tf);
```

#### Respuesta al escalon


```python
t, y = control.step_response(tf)
#plt.plot(t, y, label= "time");
fig, ax = plt.subplots()
ax.plot(t, y)

ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

##### Analiticamente llegue a la siguiente expresion

$$\begin{equation}y(t) = 10[1-3e^{-t}+3e^{-2t}-e^{-3t}]u(t)\end{equation}$$

##### Vamos a graficarla


```python
u = np.ones(t.size)

y = 10 * (1 - 3*np.exp(-t) + 3*np.exp(-2*t) - np.exp(-3*t)) * u

fig, ax = plt.subplots()
ax.plot(t, y)
ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

x)

#### Transferencia

$$\begin{equation} H(s) = 5\frac{s+4}{s^2+4s+5}\end{equation}$$

#### Ecuacion diferencial

$$\begin{equation} \frac{d^2y(t)}{dt^2} + 4\frac{dy(t)}{dt} + 5y(t) = 5\frac{dx(t)}{dt} + 20x(t) \end{equation}$$

#### Polos y ceros


```python
num = 5 * np.array([0, 1, 4])
den = np.array([1, 4, 5])

tf = control.tf(num, den)
control.pzmap(tf);
```

#### Respuesta al escalon


```python
t, y = control.step_response(tf)
#plt.plot(t, y, label= "time");
fig, ax = plt.subplots()
ax.plot(t, y)

ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

##### Analiticamente llegue a la siguiente expresion

$$\begin{equation}y(t) = 4[1-(cos(t)+\frac{3}{4}sin(t))e^{-2t}]u(t)\end{equation}$$

##### Vamos a graficarla


```python
u = np.ones(t.size)

y = 4 * (1 - (np.cos(t) + (3/4) * np.sin(t)) * np.exp(-2*t)) * u

fig, ax = plt.subplots()
ax.plot(t, y)
ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

xi)

#### Transferencia

$$\begin{equation} H(s) = \frac{s+2}{2(s+4)}\end{equation}$$

#### Ecuacion diferencial

$$\begin{equation}\frac{d^2y(t)}{dt^2} + 4\frac{dy(t)}{dt} = \frac{dx(t)}{dt} + 2x(t) \end{equation}$$

#### Polos y ceros


```python
num = np.array([0, 0, 1, 2])
den = np.array([1, 4, 0, 0])

tf = control.tf(num, den)
control.pzmap(tf);
```

#### Respuesta al escalon


```python
t, y = control.step_response(tf)
#plt.plot(t, y, label= "time");
fig, ax = plt.subplots()
ax.plot(t, y)

ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

##### Analiticamente llegue a la siguiente expresion

$$\begin{equation}y(t) = (\frac{3}{40} + \frac{1}{2}t - \frac{1}{8}e^{-4t})u(t)\end{equation}$$

##### Vamos a graficarla


```python
u = np.ones(t.size)

y = (3/40 + 0.5 * t - (1/8) * np.exp(-4*t)) * u

fig, ax = plt.subplots()
ax.plot(t, y)
ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

xii)

#### Transferencia

$$\begin{equation} H(s) = -3\frac{s-6}{s^2+6s+18}\end{equation}$$

#### Ecuacion diferencial

$$\begin{equation} \frac{d^2y(t)}{dt^2} + 6\frac{dy(t)}{dt} + 8y(t) = -3\frac{dx(t)}{dt} + 18x(t)\end{equation}$$

#### Polos y ceros


```python
num = -3 * np.array([0, 1, -6])
den = np.array([1, 6, 18])

tf = control.tf(num, den)
control.pzmap(tf);
```

#### Respuesta al escalon


```python
t, y = control.step_response(tf)
#plt.plot(t, y, label= "time");
fig, ax = plt.subplots()
ax.plot(t, y)

ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```

##### Analiticamente llegue a la siguiente expresion

$$\begin{equation}y(t) = -[(2sen(3t) + cos(3t))e^{-3t} + 1]u(t)\end{equation}$$

##### Vamos a graficarla


```python
u = np.ones(t.size)
y = ( -(2*np.sin(3*t) + np.cos(3*t)) * np.exp(-3*t) + 1 ) * u
fig, ax = plt.subplots()
ax.plot(t, y)
ax.set(xlabel='time [s]', ylabel='amplitud []', title='Step Response');
```


```python

```

afbb414a26a5c3124de1504256475865edfb4d0e
ipynb
Jupyter Notebook
TP1Notebook.ipynb
ordonezt/TP1-Control
10f4a5b11d548bf63e8379a7afed0577f4265b73
MIT
TP1Notebook.ipynb
ordonezt/TP1-Control
10f4a5b11d548bf63e8379a7afed0577f4265b73
MIT
TP1Notebook.ipynb
ordonezt/TP1-Control
10f4a5b11d548bf63e8379a7afed0577f4265b73
MIT
Qwen/Qwen-72B
1. YES
2. YES