tag:blogger.com,1999:blog-53585875745349940332024-01-02T08:24:24.399-08:00De la web www.matpic.comPython, Matlab, LaTeX, VHDL.Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.comBlogger28125tag:blogger.com,1999:blog-5358587574534994033.post-77972915617184002182021-06-17T13:17:00.003-07:002021-06-17T13:17:41.359-07:00Señales y Sistemas || Probabilidad y Variables Aleatorias<div style="text-align: center;"><iframe frameborder="0" height="360" src="https://youtube.com/embed/9kC0MsCl9GU?list=PLmDhYt8h3Ztk1-km2ZId5ZzsC-WsDHNJ9" width="480"></iframe></div>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-7311510804964593442016-11-08T08:17:00.000-08:002019-09-19T05:22:34.148-07:00Versión actualizada del manual de GUI en Matlab.<html>
<head></head>
<div align="justify">
Esta <a href="https://www.mathworks.com/matlabcentral/fileexchange/12122-handbook-of-graphical-user-interface-spanish">nueva versión</a> ha estado por mucho tiempo dentro de una carpeta escondida del PC. Luego de diez largos años llega la versión actualizada del Manual de GUI en Matlab. En el 2006, cuando apareció la primera versión, no existía un material que explique cómo crear una GUI en Matlab. De hecho, ni en YouTube existían buenos tutoriales. Y fue en ese entorno que salió ese modesto manual. No me esperaba que llegara a ser un documento de referencia para programar en Matlab, pero así fue.
</div>
<div align="justify">
Contiene correcciones de los códigos de la versión previa más el reajuste de funciones que han ido cambiando de versión en versión de Matlab.
</div>
<div align="justify">
<iframe height="850" src="https://drive.google.com/file/d/0BxCiLHI-w0ooamNzTW84YTYtdUk/preview" width="690"></iframe>
</div>
<body>
</body></html>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com2tag:blogger.com,1999:blog-5358587574534994033.post-60696443648151086442016-10-18T14:51:00.001-07:002016-10-18T14:51:55.518-07:00Propiedades de los Sistema Lineales Invariantes en el Tiempo II<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Mathedemo</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body>
<div align="justify">
<b>Sistemas LTI con y sin memoria</b>
</div>
<div align="justify">
Un sistema se considera sin memoria si su salida en cualquier tiempo depende solo del valor de la entrada en ese mismo instante de tiempo. Considerando el caso en el cual la respuesta al impulso $h[n]$ es no nula solo en el instante $n=0$, es decir, $h[n]=k\delta[n]$. Para este caso particular, la salida de la ecuación $y[n] = \sum\limits_{k = - \infty }^\infty {x[k]h[n - k]} $ dará como resultado $y[n]=kx[n]$.
</div>
<div align="justify">
En el caso de sistemas continuos, teniendo una respuesta al impulso de la misma naturaleza $h(t)=0$ solo en instantes diferentes de 0, es decir $h(t)=k\delta(t)$, la salida del sistemas también es semejante al caso anterior, siendo $y(t)=kx(t)$.
</div>
<div align="justify">
En los dos casos anteriores, cuando $k=1$, el sistema es denominado sistema identidad.
</div>
<div align="justify">
De aquí se genera una útil propiedad: toda señal que convolucione con un impulso, da como resultado la misma señal, es decir:
</div>
\begin{equation}\label{eq:sis_men_1}
\begin{matrix}
{x[n]*\delta [n] = x[n]} \cr
{x(t)*\delta (t) = x(t)} \cr
\end{matrix}
\end{equation}
<div align="justify">
Estas ecuaciones se reducen a las propiedades de selección de los impulsos unitarios:
</div>
\begin{equation}\label{eq:sis_men_2}
\begin{matrix}
{x[n] = \sum\limits_{k = - \infty }^\infty {x[k]\delta [n - k]} } \cr
{x(t) = \int\limits_{ - \infty }^\infty {x(\tau )\delta (t - \tau )} d\tau } \cr
\end{matrix}
\end{equation}
<div align="justify">
Una interpretación que se deriva de las ecuaciones precedentes que la convolución de cualquier señal con un impulso desplazado, dará como salida del sistema la misma señal, pero desplazada en la posición del impulso.
</div>
\begin{equation}\label{eq:sis_men_3}
\begin{matrix}
{x[n]*\delta [n-n_0] = x[n-n_0]} \cr
{x(t)*\delta (t-t_0) = x(t-t_0)} \cr
\end{matrix}
\end{equation}
<div align="justify">
<b>Sistemas LTI invertibles</b>
</div>
<div align="justify">
Un sistema es invertible si existe un sistema inverso que al ser colocado en cascada (o serial) da como salida la entrada del primer sistema. Suponiendo que la secuencia $x[n]$ entra a un sistema con una respuesta al impulso $h_1[n]$ y la respuesta de este sistema ingresa a otro sistema con respuesta al impulso $h_2[n]$ y el resultado o salida de este último sistema en la misma señal de entrada $x[n]$, se dice que el sistema $h_1[n]$ es invertible. En otras palabras $h_1[n]*h_2[n]=\delta[n]$ resulta en el sistema identidad.
</div>
<div align="justify">
<b>Causalidad para sistemas LTI</b>
</div>
<div align="justify">
Cuando un sistema es causal, su salida $y[n]$ depende solo de valores presentes y pasados de la entrada. Es decir, la salida no debe depender de $x[k]$ para $k>n$. Observando la ecuación de convolución discreta, notemos que se trata de la multiplicación de la función $x[k]$ y $h[n-k]$. Si todos los coeficientes de $h[n-k]$ que multiplican valores de $x[k]$ para $k>n$ son cero, el sistema es causal. Esto se logra siempre que $h[n]=0$ para $n<0$.
</div>
<div align="justify">
De esta forma, existe una simplificación en las ecuaciones de cálculo de la convolución:
</div>
\begin{equation}\label{eq:sis_causa_1}
\begin{matrix}
{y[n] = \sum\limits_{k = - \infty }^n {x[k]h[n - k]}} \cr
{y[n] = \sum\limits_{k = 0}^\infty {h[k]x[n - k]} } \cr
\end{matrix}
\end{equation}
\begin{equation}\label{eq:sis_causa_2}
\begin{matrix}
{y(t) = \int\limits_{ - \infty }^t {x(\tau )h(t - \tau )} d\tau } \cr
{y(t) = \int\limits_0^\infty {h(\tau )x(t - \tau )} d\tau } \cr
\end{matrix}
\end{equation}
<div align="justify">
<b>Estabilidad para sistemas LTI</b>
</div>
<div align="justify">
El sistema es estable cuando una entrada finita o acotada produce una salida finita o acotada. En particular, el sistema es estable si $\sum\limits_{k = - \infty }^\infty {\left| {h[k]} \right| < \infty } $ o $\int\limits_{ - \infty }^\infty {\left| {h(t)} \right| < \infty } $.
</div>
<b>Referencia</b>: Oppenheim, A., Willsky,A., Nawab, S. (1996). Signals and Systems (2nd Ed.). Prentice-Hall. Upper Saddle River, NJ, USA.</body></html>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-69263996466767311532016-08-30T13:48:00.000-07:002016-10-18T14:43:03.794-07:00Propiedades de los Sistema Lineales Invariantes en el Tiempo I<html>
<head>
<title>Mathedemo</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript">
</script>
</head>
<body>
<div align="justify">
La convolución es una operación que involucra tres señales: $x(t)$ o $x[n]$ como entrada al sistema, $h(t)$ o $h[n]$ como respuesta al impulso y $y(t)$ o $y[n]$ como salida o respuesta del sistema. Para un SLTI, éste es caracterizado por completo por la función $h(t)$ o $h[n]$. En otras palabras, la convolución es la operación que permite calcular la salida (o respuesta) de cualquier sistema lineal e invariante al tiempo para cualquier entrada a través de la respuesta al impulso.
</div>
<div align="justify">
La convolución posee varias propiedades.
</div>
<div align="justify">
<b>Propiedad conmutativa</b>
</div>
<div align="justify">
La convolución es una operación conmutativa, es decir, da el mismo resultado convolucionar la entrada con la respuesta al impulso que la respuesta al impulso por la entrada. Esta propiedad se muestra en las siguientes ecuaciones.
</div>
\begin{equation}\label{eq:conv_continua_pr}
x[n]*h[n] = h[n]*x[n] = \sum\limits_{k = - \infty }^\infty {h[k]x[n - k]}
\end{equation}
\begin{equation}\label{eq:conv_disc_pr}
x(t)*h(t) = h(t)*x(t) = \int\limits_{ - \infty }^\infty {h(\tau )x(t - \tau )d\tau }
\end{equation}
<div align="justify">
Esta propiedad es de gran utilidad cuando se realiza la convolución de forma gráfica debido a qué se puede seleccionar la señal más fácil de dibujar para que sea la que se desplace (aquella con argumento $t-\tau$ o $k-n$).
</div>
<div align="justify">
<b>Propiedad distributiva</b>
</div>
<div align="justify">
La propiedad distributiva mostrada en las ecuaciones siguientes, permite reemplazar un sistema paralelo en un equivalente de un solo sistema.
</div>
\begin{equation}\label{eq:conv_continua_dist}
x[n]*({h_1}[n] + {h_2}[n]) = x[n]*{h_1}[n] + x[n]*{h_2}[n]
\end{equation}
\begin{equation}\label{eq:conv_disc_dist}
x(t)*({h_1}(t) + {h_2}(t)) = x(t)*{h_1}(t) + x(t)*{h_2}(t)
\end{equation}
<div align="justify">
<b>Propiedad asociativa</b>
</div>
<div align="justify">
Esta propiedad, mostrada en las ecuaciones siguientes, muestra que la respuesta del sistema completo no depende del orden de los sistemas en cascada.
</div>
\begin{equation}\label{eq:conv_continua_asoc}
x[n]*({h_1}[n]*{h_2}[n]) = (x[n]*{h_1}[n])*{h_2}[n]
\end{equation}
\begin{equation}\label{eq:conv_disc_asoc}
x(t)*({h_1}(t)*{h_2}(t)) = (x(t)*{h_1}(t))*{h_2}(t)
\end{equation}
<b>Referencia</b>: Oppenheim, A., Willsky,A., Nawab, S. (1996). Signals and Systems (2nd Ed.). Prentice-Hall. Upper Saddle River, NJ, USA.</body></html>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-76685547984688864652016-08-29T10:13:00.002-07:002016-09-19T13:32:51.107-07:00Convolución continua<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Mathedemo</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body>
<div align="justify">
La convolución en tiempo continuo deriva en una integral. Semejante al caso discreto, el primer paso para llegar a esta importante ecuación es representar la señal continua $x(t)$ como una combinación lineal de impulsos ponderados desplazados. Recordando que el impulso continuo es definido como el límite de la señal $\delta_{\Delta}(t)$, cada función rectangular $\delta_{\Delta}(t)$ tiene un área $x(k\Delta)\delta_{\Delta}(t-k\Delta)\Delta$, siendo que tiene una base $\Delta$ y una altura igual a la amplitud de la señal en ese punto en particular. De ese modo, la señal escalonada $\tilde x\left( t \right)$ queda representada con la siguiente ecuación:
</div>
\begin{equation}\label{eq:x_escalonada}
\tilde x\left( t \right) = \sum\limits_{k = - \infty }^{ + \infty } {x(k\Delta ){\delta _\Delta }\left( {t - k\Delta } \right)} \Delta
\end{equation}
<div align="justify">
Cuando en esta última ecuación el valor de $\Delta$ tiende al infinito, la sumatoria se convierte en una integral, $\Delta$ en un diferencial y $\delta_{\Delta}$ deriva en la función impulso unitario continuo $\delta(t)$. Por tanto, la señal escalonada $\tilde x\left( t \right)$ en el límite representa la señal $x(t)$.
</div>
\begin{equation}\label{eq:x_escalonada1}
x(t) = \mathop {\lim }\limits_{\Delta \to 0} \tilde x\left( t \right)
\end{equation}
\begin{equation}\label{eq:x_escalonada2}
x(t) = \mathop {\lim }\limits_{\Delta \to 0} \sum\limits_{k = - \infty }^{ + \infty } {x(k\Delta ){\delta _\Delta }\left( {t - k\Delta } \right)} \Delta = \int\limits_{ - \infty }^{ + \infty } {x(\tau )} \delta (t - \tau )d\tau
\end{equation}
\begin{equation}\label{eq:x_escalonada3}
x(t) = \int\limits_{ - \infty }^{ + \infty } {x(\tau )} \delta (t - \tau )d\tau
\end{equation}
<div align="justify">
Esta ecuación representa la señal continua $x(t)$ como una combinación lineal de impulsos desplazados ponderados. También se conoce como propiedad de selección y es una representación de la señal $x(t)$ como la suma de impulsos continuos ponderados y desplazados. (La ponderación significa que el impulso es multiplicado por una constante.)
</div>
<div align="justify">
Podemos mostrar que esta ecuación representa a $x(t)$ cuando $\Delta$ tiende a $0$.
</div>
\begin{equation}\label{eq:x_de_tau}
\int\limits_{ - \infty }^{ + \infty } {x(\tau )\delta (t - \tau )d\tau } = \int\limits_{ - \infty }^{ + \infty } {x(t)\delta (t - \tau )d\tau } = x(t)\int\limits_{ - \infty }^{ + \infty } {\delta (t - \tau )d\tau } = x(t)
\end{equation}
<div align="justify">
Notar que aplicamos la propiedad de que si una función se multiplica por un impulso desplazados, el resultado será la función evaluada en el desplazamiento del impulso multiplicada por el impulso ($x(t)\delta (t - {t_0}) = x({t_0})\delta (t - {t_0})$). Una vez hecho esto, basta notar que $x(t)$ sale de la integral ya que no es función de $\tau$ y la integral del impulso es igual a 1.
</div>
<div align="justify">
Una vez que la señal de entrada $x(t)$ ha sido descompuesta o representada como una combinación lineal de impulsos continuos desplazados y ponderados, se puede calcular la respuesta de un sistema LTI a esta entrada $x(t)$. Denominamos $\hat y(t)$ como la salida o respuesta del sistema cuando la entrada es la señal $\tilde x$. Ésta respuesta corresponde a la superposición de las respuestas a las versiones escaladas y desplazadas de $\delta_\Delta(t)$, mostrada en la siguiente ecuación.
</div>
\begin{equation}\label{eq:resp_delta}
{\delta _\Delta }\left( {t - k\Delta } \right) \to {{\hat h}_{k\Delta }}\left( t \right)
\end{equation}
\begin{equation}\label{eq:y_sombrero}
\hat y(t) = \sum\limits_{k = - \infty }^\infty {x(k\Delta )} {{\hat h}_{k\Delta }}\left( t \right)\Delta
\end{equation}
<div align="justify">
Dado que $x(t) = \mathop {lim}\limits_{\Delta \to 0 } \hat x(t)$, en consecuencia $y(t) = \mathop {lim}\limits_{\Delta \to 0 } \hat y(t)$. Cuando $\Delta \to 0$, la duración de ${\delta _\Delta }\left( {t - k\Delta } \right)$ no es significativa, así, la respuesta a esta señal será la respuesta a un impulso unitario en el mismo instante de tiempo. De esta forma ${{\hat h}_{k\Delta }}\left( t \right)$ se convierte en la respuesta al impulso en el límite. Si $\delta (t - \tau ) \to {h_\tau }(t)$, entonces la salida queda determinada por la ecuación siguiente.
</div>
\begin{equation}\label{eq:y_limite}
y(t) = \mathop {lim}\limits_{\Delta \to 0} \sum\limits_{k = - \infty }^\infty {x(k\Delta )} {{\hat h}_{k\Delta }}\left( t \right)\Delta
\end{equation}
<div align="justify">
Conforme $\Delta \to 0$, la sumatoria se convierte en una integral, dando como resultado la ecuación mostrada a continuación.
</div>
\begin{equation}\label{eq:conv_temp}
y(t) = \int\limits_{ - \infty }^\infty {x(\tau )} {h_\tau }(t)d\tau
\end{equation}
<div align="justify">
Esta ecuación representa la superposición de las respuestas para un sistema lineal a cada una de las entradas cuando $x(t)$ es representado como la ecuación $\tilde x$.
</div>
<div align="justify">
Si el sistemas lineal también es un sistema invariante al tiempo, las respuesta a impulsos desplazados serán respuestas desplazadas del impulso $\delta(t)$, conforme la ecuación siguiente.
</div>
\begin{equation}\label{eq:sist_inv_temp}
{h_\tau }(t) = {h_0}(t - \tau )
\end{equation}
<div align="justify">
En otras palabras, cuando el sistema es lineal e invariante al tiempo (SLTI), la respuesta de este sistema cuando la entrada es $\delta(t-\tau)$, es una versión desplazada en $\tau$ de la respuesta del sistema cuando la entrada es $\delta(t)$ (ecuación siguiente).
</div>
\begin{equation}\label{eq:delta_tau}
\delta (t - \tau ) \to h(t - \tau )
\end{equation}
<div align="justify">
De esa forma, a partir de la linealidad del sistema y añadiendo la invarianza al tiempo, llegamos a la integral de convolución mostrada en la ecuación siguiente, con la cual podemos afirmar que un SLTI está por completo caracterizado si conocemos su respuesta al impulso $h(t)$.
</div>
\begin{equation}\label{eq:conv_continua}
y(t) = \int\limits_{ - \infty }^\infty {x(\tau )} h(t - \tau )d\tau
\end{equation}
<div align="justify">
Una notación alternativa de la convolución es mostrada en la siguiente ecuación.
</div>
\begin{equation}\label{eq:conv_continua_alta}
y(t) = x(t)*h(t)
\end{equation}
<b>Referencia</b>: Oppenheim, A., Willsky,A., Nawab, S. (1996). Signals and Systems (2nd Ed.). Prentice-Hall. Upper Saddle River, NJ, USA.
Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-5760162350467806402016-05-11T08:45:00.000-07:002016-09-19T13:40:19.231-07:00Convolución discreta<html>
<head>
<title>Convolución discreta</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body>
<div align="justify">
Una de las propiedades más importantes de los sistemas es la linealidad. Esta propiedad a su vez se divide en dos propiedades conocidas como propiedad aditiva y propiedad de escalamiento. La propiedad aditiva establece que si al sistema ingresa la suma de varias señales, la respuesta del sistema será la suma de las respuestas a cada una de las entradas individuales.
</div>
<div align="justify">
La propiedad de escalamiento u homogeneidad establece que si una señal $x(t)$ tiene como respuesta una señal $y(t)$, al ser escalada la entrada (o multiplicada por una constante) $\alpha x(t)$, su salida será también escalada por la misa constante $\alpha y(t)$. Juntas, la propiedad de escalamiento y la aditiva se conocer como propiedad de superposición, la cual se sintetiza en la siguiente ecuación.
</div>
\begin{equation}\label{eq:superpos_1}
\alpha {x_1}\left( t \right) + \beta {x_2}\left( t \right) \to \alpha {y_1}\left( t \right) + \beta {y_2}\left( t \right)
\end{equation}
<div align="justify">
Otra de las propiedad importante de los sistemas es la propiedad de invarianza la tiempo, detallada en la siguiente ecuación.
</div>
\begin{equation}\label{eq:inv_tiempo}
\begin{matrix}
{x\left( t \right) \to y\left( t \right)} \cr
{x\left( {t - {t_0}} \right) \to y\left( {t - {t_0}} \right)} \cr
\end{matrix}
\end{equation}
<div align="justify">
En sí, un sistema es invariante al tiempo cuando una desplazamiento en la señal de entrada produce el mismo desplazamiento en la señal de salida o respuesta del sistema. Es decir, el sistema no cambia sus características a lo largo del tiempo.
</div>
<div align="justify">
Cuando un sistema cumple con la propiedad de linealidad (o propiedad de superposición) y la propiedad de ser invariante al tiempo se conoce como sistema lineal e invariante al tiempo, abreviado como SLTI. Muchos sistemas empleados en comunicaciones son SLTI. De ahí la importancia de conocer las características de este tipo de sistema y la forma de encontrar la respuesta del mismo o salida del sistema.
</div>
<div align="justify">
Para un sistema discreto, la forma de encontrar la salida de este sistema es a través de una operación conocida como suma de convolución. Para llegar a este resultado, lo primero es representar la señal discreta $x[n]$ como una combinación lineal del impulsos desplazados ponderados.
</div>
\begin{equation}\label{eq:impulso_des_pond}
x\left[ n \right] = \sum\limits_{k = - \infty }^{ + \infty } {x\left[ k \right]\delta [n - k]}
\end{equation}
<div align="justify">
Dado que el sistema es lineal, la respuesta será también una combinación lineal, pero de las respuestas a cada una de las entradas individuales. Como la señal ha sido representada como una suma de señales impulso, la respuesta a esta señal se asigna de la siguiente manera:
</div>
\begin{equation}\label{eq:impulso_des_pond2}
\delta [n - k] \to {h_k}[n]
\end{equation}
<div align="justify">
De esa forma, la salida total del sistema será la superposición de las salidas a cada una de las entradas.
</div>
\begin{equation}\label{eq:impulso_des_pond3}
y\left[ n \right] = \sum\limits_{k = - \infty }^{ + \infty } {x\left[ k \right]{h_k}[n]}
\end{equation}
<div align="justify">
Si el sistema es invariante al tiempo, la respuesta a un impulso desplazado será la misma respuesta a un impulso en $n=0$ simplemente desplazada.
</div>
\begin{equation}\label{eq:impulso_des_pond4}
\delta [n - k] \to {h_0}[n - k]
\end{equation}
<div align="justify">
De esa forma, la salida del sistema es calculada con la siguiente ecuación, que es conocida como la suma de convolución o convolución discreta.
</div>
\begin{equation}\label{eq:impulso_des_pond5}
y\left[ n \right] = \sum\limits_{k = - \infty }^{ + \infty } {x\left[ k \right]h[n - k]}
\end{equation}
<b>Referencia</b>: Oppenheim, A., Willsky,A., Nawab, S. (1996). Signals and Systems (2nd Ed.). Prentice-Hall. Upper Saddle River, NJ, USA.
Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-31826731574708778822016-05-05T14:11:00.002-07:002016-09-19T13:41:41.940-07:00Impulso y escalón unitarios<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Impulso y escalón unitario</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body>
La estrategia para procesar o tratar una señal es representar (o descomponer) dicha señal en una combinación lineal de señales base. En el análisis de la señal en el tiempo, dicha señal base es el impulso unitario $\delta[n]$ (para tiempo discreto) y $\delta(t)$ para tiempo continuo. Un impulso discreto está definido conforme la siguiente ecuación.
\begin{equation}\label{eq:impul_discreto}
\delta \left[ n \right] = \left\{ \begin{matrix}
{1,} & {n = 0} \cr
{0,} & {n \ne 0} \cr
\end{matrix} \right.
\end{equation}
Es decir, un impulso es una señal que tiene un valor no nulo apenas en un instante de tiempo.
<!--{pics/impulso_unitario_discreto.png} -->
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD2NZ65Pm0S3W5G7iqPj0OORwbBUnBzrEmqgDvAKioMayhuTIQOhlFzz8b0jielK_Vn4jSOZXoZ0bq_dui3CW617qeE7SFvQ24TrQv1ZM-5iXGxwjq1UcGx4nIywtVoZE878jIT0IO2IM/s1600/impulso_unitario_discreto.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD2NZ65Pm0S3W5G7iqPj0OORwbBUnBzrEmqgDvAKioMayhuTIQOhlFzz8b0jielK_Vn4jSOZXoZ0bq_dui3CW617qeE7SFvQ24TrQv1ZM-5iXGxwjq1UcGx4nIywtVoZE878jIT0IO2IM/s400/impulso_unitario_discreto.png" /></a></div>
El escalón unitario discreto es aquella señal que puede considerarse constante a partir del instante 0. Se denota como $u[n]$.
\begin{equation}\label{eq:esca_discreto}
u\left[ n \right] = \left\{ \begin{matrix}
{1,} & {n \ge 0} \cr
{0,} & {n < 0} \cr
\end{matrix} \right.
\end{equation}
En la gráfica de la Figura siguiente del escalón se observa que de alguna forma puede ser representado como un conjunto de señales impulso.
<!-- {pics/escalon_discreto.png} -->
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwAqkTAbVv__hFsNRU6J7XdLiX36Bp_6gRx10B-fdl-nIHTdT-dMOx6YUK-1pA0npmTT5cTsMmeh5bCodDjffqZvZnboyMLYYO5zqrUk58ngpYJc_dXugLGdywRrh4yb7oIT_aZGNbp_Q/s1600/escalon_discreto.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwAqkTAbVv__hFsNRU6J7XdLiX36Bp_6gRx10B-fdl-nIHTdT-dMOx6YUK-1pA0npmTT5cTsMmeh5bCodDjffqZvZnboyMLYYO5zqrUk58ngpYJc_dXugLGdywRrh4yb7oIT_aZGNbp_Q/s400/escalon_discreto.png" /></a></div>
Es así, que el escalón unitario discreto puede generarse a partir del impulso unitario a través de la siguiente ecuación.
\begin{equation}\label{eq:esca_discreto_imp1}
u[n] = \sum\limits_{k = 0}^{ + \infty } {\delta \left[ {n - k} \right]}
\end{equation}
En esta última ecuación, el impulso se va desplazando dentro de una ventana fija del sumatorio. Una expresión alternativa es presentada en la siguiente ecuación, donde la ventana del sumatorio es móvil y el impulso fijo.
\begin{equation}\label{eq:esca_discreto_imp2}
u[n] = \sum\limits_{m = - \infty }^n {\delta [m]}
\end{equation}
Un impulso puede obtenerse a partir de la primera diferencia del escalón a través de la ecuación siguiente.
\begin{equation}\label{eq:esca_discreto_imp3}
\delta \left[ n \right] = u[n] - u[n - 1]
\end{equation}
En tiempo continuo, el escalón e impulso unitario tienen una representación semejante. Un escalón unitario continuo está definido conforme la ecuación siguiente.
\begin{equation}\label{eq:esca_continuo}
u(t) = \left\{ \begin{matrix}
{1,} & {t > 0} \cr
{0,} & {t < 0} \cr
\end{matrix} \right.
\end{equation}
Esta señal es constante a partir de $t>0$.
<!-- {pics/escalon_continuo.png} -->
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu9rR4HFLok5VMnG2gEz9fZAJVPLlNP-__4FCUzH7TmNQJyP8hhjGAegKSGylw_tExtYqYmp9a16CLc_Rj8uYnp8QXfTDQmYpTZUlHC9fRFgUvs09pVlM2vXwdqFo3Z9YBtDpn8AxvvQ0/s1600/escalon_continuo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu9rR4HFLok5VMnG2gEz9fZAJVPLlNP-__4FCUzH7TmNQJyP8hhjGAegKSGylw_tExtYqYmp9a16CLc_Rj8uYnp8QXfTDQmYpTZUlHC9fRFgUvs09pVlM2vXwdqFo3Z9YBtDpn8AxvvQ0/s400/escalon_continuo.png" /></a></div>
Para definir al impulso unitario, usamos la función $\delta_{\delta}(t)$ detallada en la ecuación siguiente.
\begin{equation}\label{eq:delta_sub_Delta}
{\delta _\Delta }(t) = \left\{ \begin{matrix}
{{1 \over \Delta },} & {0 < t < \Delta } \cr
{0,} & {otro{\kern 1pt} {\kern 1pt} {\kern 1pt} valor} \cr
\end{matrix} \right.
\end{equation}
Esta señal $\delta_{\delta}(t)$ tiene siempre área igual a uno para todo valor de $\Delta$. De esa forma, el impulso unitario se define como el límite de esta señal cuando $\Delta$ tiende a cero.
\begin{equation}\label{eq:delta_sub_Delta2}
\delta (t) = \mathop {\lim }\limits_{\Delta \to 0} {\delta _\Delta }(t)
\end{equation}
La gráfica del impulso unitario continuo es semejante al impulso discreto, con la diferencia que el valor que se colocar cerca de la flecha es su área.
<!-- {pics/impulso_unitario_continuo.png} -->
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEnPwgnXqF4iaRRCl0Xld4f9EelHwOyW1_uQwI08wOL0sRRfFDWIgbD60zdw8UtQ4xgaXD0TJPsaL1Z_mnrA7iul-1ksM6iJKeDns_xoA2PknV28E4doOBxGPZ1kPv0xXu0GbCNNT5ZQw/s1600/impulso_unitario_continuo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEnPwgnXqF4iaRRCl0Xld4f9EelHwOyW1_uQwI08wOL0sRRfFDWIgbD60zdw8UtQ4xgaXD0TJPsaL1Z_mnrA7iul-1ksM6iJKeDns_xoA2PknV28E4doOBxGPZ1kPv0xXu0GbCNNT5ZQw/s400/impulso_unitario_continuo.png" /></a></div>
Tal como el caso discreto, el impulso se puede obtener a partir del escalón a través de la derivada usando la ecuación siguiente.
\begin{equation}\label{eq:delta_escalon_1}
\delta (t) = {{\partial u(t)} \over {\partial t}}
\end{equation}
Y el escalón a través del impulso con las ecuaciones siguientes.
\begin{equation}\label{eq:delta_escalon_2}
u(t) = \int\limits_{ - \infty }^t {\delta (\tau )} d\tau
\end{equation}
\begin{equation}\label{eq:delta_escalon_3}
u(t) = \int\limits_0^\infty {\delta (t - \sigma )} d\sigma
\end{equation}
<b>Referencia</b>: Oppenheim, A., Willsky,A., Nawab, S. (1996). Signals and Systems (2nd Ed.). Prentice-Hall. Upper Saddle River, NJ, USA.Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-27860903566231677432016-05-04T10:08:00.001-07:002016-05-04T10:08:38.221-07:00Exponencial periódica compleja<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Exponencial periódica compleja</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body>
<div align="justify">
Una señal $x(t)$ es periódica si se repite su formato a lo largo del tiempo. Matemáticamente, una señal es periódica si cumple $x(t)=x(t+T)$ para todo tiempo $t$, donde $T$ es el periodo de la señal. Este periodo es un número mayor que cero y está definido como el mínimo tiempo para el cual $x(t)=x(t+T)$ se cumple.
</div>
<div align="justify">
Una clase particular de señales continuas periódicas son las exponenciales complejas $e^{j\omega_0 t}$, donde $\omega_0$ es la frecuencia angular medida en radianes por segundo (rad/s). Esta señal es periódica con periodo $T=2\pi/\omega_0$. La frecuencia angular $\omega_0$ también se puede expresar en hertz (Hz) usando la relación $\omega_0=2\pi f$, donde $f$ es la frecuencia nominal. Si usamos la relación de Euler $e^{j\omega_0t}=cos(\omega_0t)+jsen(\omega_0t)$ podemos notar que en sí una exponencial compleja es un par de señales senoidales.
</div>
<div align="justify">
Esta señal exponencial compleja es muy importante en el procesamiento de una señal debido a que es una auto-función (o eigen-función) de los sistemas lineales e invariantes al tiempo (SLTI). Es decir, si una exponencial compleja continua entra a un SLTI, la respuesta de este sistema es la misma exponencial compleja simplemente multiplicada por una constante compleja $H(s)$ (llamado eigen-valor). Esto lo veremos en la parte del análisis de Fourier de señales.
</div>
<div align="justify">
En el caso de las exponenciales complejas discretas $x[n]=e^{j\omega_0n}$, no toda exponencial compleja es periódica. Se debe cumplir que $\omega_0/2\pi$ debe ser un número racional $M/N$ , donde $N$ es el periodo que es igual a $N=\omega_0/2\pi$. Otra diferencia con su contra parte continua es que esta señal es periódica cada $2\pi$, es decir $e^{j\omega_0n}=e^{j(\omega_0+2\pi)n}$. Conforme la frecuencia angular va de 0 a $\pi$, la frecuencia de esta señal aumenta y mientras va de $\pi$ hasta $2\pi$ la frecuencia disminuye. Es así, que si una señal exponencial compleja tiene su concentración de frecuencia en torno de 0, $2\pi$ o múltiplos pares de $\pi$ se dice que es una señal de baja frecuencia. Si su frecuencia está concentrada en torno de $\pi$ o múltiplos impares de $\pi$, es una señal de alta frecuencia.
</div>
Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-37471879014233804632016-04-13T08:17:00.000-07:002016-09-19T13:42:04.565-07:00Transformación de la variable independiente<html>
<head>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript">
</script>
<script src="http://latex.codecogs.com/latexit.js" type="text/javascript"></script>
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
<div align="justify">
En las señales en tiempo continuo $x\left( t \right)$ (variable independiente $t$) o tiempo discreto $x\left[ n \right]$ (variable independiente $n$) se modifica de tres maneras su variable independiente.
</div>
<div align="justify">
<b>1. Desplazamiento o corrimiento</b>($x\left( {t - {t_0}} \right)$): dividida en adelanto y atraso dependiendo si el valor de ${t_0}$ es mayor o menor que cero (es decir, si es positivo o negativo).</div>
<div align="justify">
Considerando un escalón unitario discreto, una señal $x[n-3]$ corresponderá a un escalón atrasado tres muestras. En sí, esta nueva señal tendrá un desplazamiento hacia la derecha del eje. Este tipo de transformación es denominada atraso de la señal.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgid7dppFspDoJOZlR_z-kOlRYKFxXGOIAO5NvskpowGkJjwPrhhP1mL0v3DbVeAOnIMeJLhsALlz3YdZftiDJpJkUI1C9tj-AYqOuvDGyUnBA_dwedjLjLjINlqyhymundvV-Ife1ImXc/s1600/atraso_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgid7dppFspDoJOZlR_z-kOlRYKFxXGOIAO5NvskpowGkJjwPrhhP1mL0v3DbVeAOnIMeJLhsALlz3YdZftiDJpJkUI1C9tj-AYqOuvDGyUnBA_dwedjLjLjINlqyhymundvV-Ife1ImXc/s400/atraso_1.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<div align="justify">
El adelanto en el tiempo de una señal se muestra en la siguiente figura, donde se grafica la función $x[n+3]$
</div>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAZ7zxlgVvYVFjNj8BQdkJ1EwItCM_6JqYApFkKH-XMgG4Zj15Bq2V8TwYVELP3RhNgRoRqpRhfgtmbKm6SCxDDRrd8W0PwLXRMv7aQpwEWrZ7PwubjefuUfmtYWnYwSuqZ30ZlMfYWFk/s1600/adelanto_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAZ7zxlgVvYVFjNj8BQdkJ1EwItCM_6JqYApFkKH-XMgG4Zj15Bq2V8TwYVELP3RhNgRoRqpRhfgtmbKm6SCxDDRrd8W0PwLXRMv7aQpwEWrZ7PwubjefuUfmtYWnYwSuqZ30ZlMfYWFk/s400/adelanto_1.png" /></a></div>
<div align="justify">
Para el tiempo continuo $t$ es un comportamiento semejante: un adelante corresponde a un corrimiento de la señal hacia la izquierda. Si el corrimiento es hacia la derecha, se considera que la señal ha sido atrasada.
</div>
<div align="justify">
<b>2. Reflejo o inversión</b>($x(-t)$ o $x[-n]$): esta transformación mapea toda la información desde 0 al otro lado del eje. Es semejante a colocar un espejo sobre el eje $y$ y observar el "reflejo" de la señal o dibujar la señal en una hoja de papel y observarla desde la parte de atrás de la hoja. Así, las señales de las figuras siguientes son el reflejo una de otra.
</div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuZBzxU7AzhcN51Y2E-6aEqTzjzsQnz0hc8xlg3zCgyLJ2bGm6By2VH8ZWiT7vQgShmOTHkEe3A1cTFs_CyBfhvYhVmURH6GPdHqgQPCU_fcUDZQC6_8LCPR3J3DK-ZxkctVzcwpHOkKQ/s1600/reflejo_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuZBzxU7AzhcN51Y2E-6aEqTzjzsQnz0hc8xlg3zCgyLJ2bGm6By2VH8ZWiT7vQgShmOTHkEe3A1cTFs_CyBfhvYhVmURH6GPdHqgQPCU_fcUDZQC6_8LCPR3J3DK-ZxkctVzcwpHOkKQ/s400/reflejo_1.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiB0Q7y8PgWLCtNIfr2-Brljuc9X-UyTImwGGsaNu8IEbqIeSi1UnQxVLOXXl2uqvdubm8ZLM1o7MGEtSGQFPzUOgoaEnMIGbY8lB77YYVVy-yv80ikHqmZRJa_WSTXuymkv5-H845jfc/s1600/reflejo_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiB0Q7y8PgWLCtNIfr2-Brljuc9X-UyTImwGGsaNu8IEbqIeSi1UnQxVLOXXl2uqvdubm8ZLM1o7MGEtSGQFPzUOgoaEnMIGbY8lB77YYVVy-yv80ikHqmZRJa_WSTXuymkv5-H845jfc/s400/reflejo_2.png" /></a></div>
<div align="justify">
<b>3. Escalamiento</b>($x(\alpha t)$): esta transformación corresponde a comprimir la señal o expandirla en el tiempo. La señal se comprime cuando $\alpha$ es mayor que uno y se expande cuando $\alpha$ es fracción.
</div>
<div align="justify">
Considerando la señal rectangular de la figura siguiente:
</div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7gl-VGvzLtGgMPju-XBnhbF8-Zc2V1pu4K0jhAEUQ6C9zLBNHWkL3w8UHbxd2JWPVVBJmrM1DJPNINS5rNl-1bq0LHfcWSLX3eYiErDZQZPjWYnVSyD7_hRs29PQfKlHIAgS1UlWT9lI/s1600/escala_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7gl-VGvzLtGgMPju-XBnhbF8-Zc2V1pu4K0jhAEUQ6C9zLBNHWkL3w8UHbxd2JWPVVBJmrM1DJPNINS5rNl-1bq0LHfcWSLX3eYiErDZQZPjWYnVSyD7_hRs29PQfKlHIAgS1UlWT9lI/s400/escala_1.png" /></a></div>
<div align="justify">
Una transformación por $\alpha=2$ produce en la señal una reducción en su duración.
</div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_HdCTUZMbfeW333EjVR7lZerQ4ldYcZPck9HKUmXyFMUfj3iGpDvFf3AszLmqVW6xHL2prXM684cJiTQb2_Kzh3w0M4qUUnWu5jwfYdQ4F7s3tZAmBNL6teIPnO1215KYmmh6qFQeElU/s1600/escala_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_HdCTUZMbfeW333EjVR7lZerQ4ldYcZPck9HKUmXyFMUfj3iGpDvFf3AszLmqVW6xHL2prXM684cJiTQb2_Kzh3w0M4qUUnWu5jwfYdQ4F7s3tZAmBNL6teIPnO1215KYmmh6qFQeElU/s400/escala_2.png" /></a></div>
<div align="justify">
Una transformación por $\alpha=0.5$ produce en la señal una ampliación en su duración.
</div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglI534OLlMsE2Z2mDWeYoZwBXAJQ87roefX-Ty633nStC0Tk4P7qjlf6-YGzcoT3v9nH9P1_JKhQliIiLBtlVQvHpCRsi8SAi0C27Fj0U83PDzhmKAnrFds69R4b6vswuTYHNbm8PDLwI/s1600/escala_3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglI534OLlMsE2Z2mDWeYoZwBXAJQ87roefX-Ty633nStC0Tk4P7qjlf6-YGzcoT3v9nH9P1_JKhQliIiLBtlVQvHpCRsi8SAi0C27Fj0U83PDzhmKAnrFds69R4b6vswuTYHNbm8PDLwI/s400/escala_3.png" /></a></div>
<b>Referencia</b>: Oppenheim, A., Willsky,A., Nawab, S. (1996). Signals and Systems (2nd Ed.). Prentice-Hall. Upper Saddle River, NJ, USA.
</head></html>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-21590892442964820932016-03-16T15:01:00.001-07:002016-08-29T13:30:21.563-07:00Papito no nació para las ocho horas<html>
<head>
<script src="http://latex.codecogs.com/latexit.js" type="text/javascript"></script>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
</head>
<body>
<p align="justify">
Sin duda uno de los mejores descubrimientos del 2013 fue Cuarteto de Nos. Una combinación extraordinaria de rima, humor, sarcasmo y realismo hacen de muchas de las canciones de este grupo uruguayo verdaderas joyas de la música. Y una de ellas, Pobre Papá, me dejó pensando en las ocho horas de trabajo diario. Así que un día usé el fenomenal Python y línea tras línea conseguí un código que marca el horario de salida del trabajo.
</p>
<p align="justify">
Este sencillo código lo he venido usando ya bastante tiempo. Le doy F5 todos los días.
</p>
<p align="justify">
Leyendo el extraordinario libro <a href="http://tinyurl.com/gndlwfl">Abre tu mente a los números</a> de la Dra. Barbara Oakley descubrí una idea interesante: el trabajo duro combinado con un ocio saludable es una combinación que mejora nuestra productividad en los estudios (o el trabajo).
</p>
<p align="justify">
Así que aquí está: saber la hora exacta de salida de esas ocho horas que se aprovecharon usando <a href="http://tinyurl.com/nnkjo8y">el modo concentrado y el modo difuso</a>...
</p>
<pre class="prettyprint lang-python linenums">
hora_ent_m =7
minuto_ent_m =32
hora_sal_m =12
minuto_sal_m =44
hora_ent_t =14
minuto_ent_t =33
print(str(hora_ent_m)+':'+str(minuto_ent_m))
print(str(hora_sal_m)+':'+str(minuto_sal_m))
print(str(hora_ent_t)+':'+str(minuto_ent_t))
hora_m=hora_sal_m-hora_ent_m;
minu_m=minuto_sal_m-minuto_ent_m;
if minu_m<0:
hora_m=hora_m-1;
minu_m=60+minu_m;
print('-'*40)
print('Horas manana: '+str(hora_m)+':'+str(minu_m))
#Restan
rth=7-hora_m
rtm=60-minu_m
if rtm>=60:
rtm=00;
rth=rth+1
if rtm<10:
print('Horas restantes: '+str(rth)+':0'+str(rtm))
else:
print('Horas restantes: '+str(rth)+':'+str(rtm))
#Salida
hora_salida=hora_ent_t+rth
minuto_salida=minuto_ent_t+rtm
if minuto_salida>=60:
minuto_salida=minuto_salida-60
hora_salida=hora_salida+1
if minuto_salida<10:
print('Hora de salida: '+str(hora_salida)+':0'+str(minuto_salida))
else:
print('Hora de salida: '+str(hora_salida)+':'+str(minuto_salida))
</pre>
Aquí el resultado:
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSFTh7SSywe3MLKWFfccjq_M0dBceQyE8XOzupARTwNzS8dK7SQGs5n1YfzMzmDjUhujA2ixC214_PYXsH9jv2MTsjs1s6sfyqNu1WCEmW40PF7z-3CfiPJKiad8H_gL-AweE0GxkTN9o/s1600/python_8_horas.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSFTh7SSywe3MLKWFfccjq_M0dBceQyE8XOzupARTwNzS8dK7SQGs5n1YfzMzmDjUhujA2ixC214_PYXsH9jv2MTsjs1s6sfyqNu1WCEmW40PF7z-3CfiPJKiad8H_gL-AweE0GxkTN9o/s320/python_8_horas.png" /></a></div>
</10:></10:></0:>
</body>
</html>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com2tag:blogger.com,1999:blog-5358587574534994033.post-84564305322731541032015-12-17T13:17:00.003-08:002015-12-17T13:20:05.965-08:00Captura de vídeo en GUI Matlab<html>
<head>
<script src="http://latex.codecogs.com/latexit.js" type="text/javascript"></script>
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
</head>
<body>
Con este programa se pretende mostrar la forma de capturar vídeo e imágenes en una interfaz gráfica.
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDs9xckB5HuZGFlmupprshgX4hiyqAvrQXfexyEXmw_7NZLzvJTS1kIGDWOqdzR_NHKN3SW9e-_tQXU2Cp_QTZwj8JVmqzWuqPYMGT1HFIyUD6oFjA2K5gDZujXbz_9Sr7UyehX9BeOdc/s1600/3_GUI_video_gui_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDs9xckB5HuZGFlmupprshgX4hiyqAvrQXfexyEXmw_7NZLzvJTS1kIGDWOqdzR_NHKN3SW9e-_tQXU2Cp_QTZwj8JVmqzWuqPYMGT1HFIyUD6oFjA2K5gDZujXbz_9Sr7UyehX9BeOdc/s640/3_GUI_video_gui_1.png" /></a></div>
El campo <i>tag</i> del axes que presenta el vídeo es axes1 y del axes que contiene la imagen capturada es axes2. El código en la sección de inicialización del programa es el siguiente:
<pre class="prettyprint lang-matlab linenums">
function video_gui_OpeningFcn(hObject, eventdata, handles, varargin)
movegui(hObject,'center')
set(handles.axes1,'XTick',[ ],'YTick',[ ])
set(handles.axes2,'XTick',[ ],'YTick',[ ])
imaqreset
handles.output = hObject;
guidata(hObject, handles);
</pre>
Con la herramienta <i>Object browser</i> podemos ver el campo <i>tag</i> de cada elemento de la GUI. (Ver Figura siguiente).
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAvoN6uKYLmPwEEYfqqB_ILoc-P9k2m6bjgxquy5-6NC1SVL5qW6Mzfhh0025S5jy8ojGhC_j3Z632oeMLbKquDbqIvHpKzN56JJ_iQ_Du_PDBr5QZaeaUmYL18MoRFXLxI38KEz3zbjk/s1600/3_GUI_video_gui_3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAvoN6uKYLmPwEEYfqqB_ILoc-P9k2m6bjgxquy5-6NC1SVL5qW6Mzfhh0025S5jy8ojGhC_j3Z632oeMLbKquDbqIvHpKzN56JJ_iQ_Du_PDBr5QZaeaUmYL18MoRFXLxI38KEz3zbjk/s320/3_GUI_video_gui_3.png" /></a></div>
El botón de inicio de la GUI abre un programa que de forma automática detecta las cámaras de vídeo (Ver Figura siguiente).
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5yZhsMjvotesULv0ql9QUtdZP8RY7GhFSlqEHPmHAVlLSvqmDrNJb5jtCHGZ7g6WP8kYT70xvRrMPrXFiS7239p3-oaDID5EodJ7Ef5SxaLa0wzVkS-cs7F_9lF8IxvUlYYj0fnJ6XK4/s1600/3_GUI_video_gui_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5yZhsMjvotesULv0ql9QUtdZP8RY7GhFSlqEHPmHAVlLSvqmDrNJb5jtCHGZ7g6WP8kYT70xvRrMPrXFiS7239p3-oaDID5EodJ7Ef5SxaLa0wzVkS-cs7F_9lF8IxvUlYYj0fnJ6XK4/s320/3_GUI_video_gui_2.png" /></a></div>
En la función de apertura contiene el código del Listado siguiente.
<pre class="prettyprint lang-matlab linenums">
function sel_camera_OpeningFcn(hObject, eventdata, handles, varargin)
imaqreset;
set(handles.ok_b,'Enable','off')
hw=imaqhwinfo('winvideo');
handles.cam=hw;
set(handles.lista_camaras,'String',{hw.DeviceInfo.DeviceName})
handles.output = hObject;
guidata(hObject, handles);
</pre>
Con el <i>pop up menu</i> seleccionamos qué cámara usar. Dentro de la función asociada a este elemento (mostrada en el Listado siguiente) está la programación que extrae las principales características de la cámara seleccionada.
<pre class="prettyprint lang-matlab linenums">
function lista_camaras_Callback(hObject, eventdata, handles)
pos=get(handles.lista_camaras,'Value');
hw=handles.cam;
id=hw.DeviceIDs{pos};
set(handles.id_camara,'String',id)
formatos=hw.DeviceInfo(pos).SupportedFormats;
set(handles.formatos,'String',formatos)
list_f = [formatos{1:end}];
si=strfind(list_f,'RGB24_320x240');
if isempty(si)
es_web_ext=0;% Laptop: YUY2
else
es_web_ext=1;% External: RGB
end
handles.es_web_ext=es_web_ext;
handles.id=id;
guidata(hObject, handles)
set(handles.ok_b,'Enable','on')
</pre>
Al presionar el botón Ok se exportan las características de la cámara seleccionada. El Listado siguiente contiene el código de la función del botón. Note que se usan variables globales para exportar esta información a la primera GUI.
<pre class="prettyprint lang-matlab linenums">
function ok_b_Callback(hObject, eventdata, handles)
global id es_web_ext
es_web_ext = handles.es_web_ext;
id = handles.id;
close (handles.camara)
</pre>
Regresando a la programación del la primera GUI, una vez seleccionada la fuente de vídeo, el botón de inicio muestra la secuencia de imágenes en el primer axes de la GUI (Ver Listado siguiente).
<pre class="prettyprint lang-matlab linenums">
function inicio_b_Callback(hObject, eventdata, handles)
set(handles.inicio_b,'Enable','off')
start(handles.vidobj);
vidRes = get(handles.vidobj,'VideoResolution');
nBands = get(handles.vidobj,'NumberOfBands');
hImage = image(zeros(vidRes(2), vidRes(1), nBands),'Parent',handles.axes1);
preview(handles.vidobj,hImage);
guidata(hObject, handles);
</pre>
Con el botón de captura, cuya programación se muestra en el Listado siguiente, obtenemos la imagen a partir del vídeo.
<pre class="prettyprint lang-matlab linenums">
function captura_Callback(hObject, eventdata, handles)
try
rgb = getsnapshot(handles.vidobj);
if handles.es_web_ext==0
rgb = ycbcr2rgb(rgb);
end
image(rgb,'Parent',handles.axes2);
axes(handles.axes2)
axis off
catch
disp('No hay imagen para mostrar')
end
</pre>
Finalmente, el botón de parada detiene la proyección de vídeo y permitirá seleccionar una nueva fuente de vídeo. (Ver Listado siguiente.)
<pre class="prettyprint lang-matlab linenums">
function parar_b_Callback(hObject, eventdata, handles)
set(handles.inicio_b,'Enable','on')
stoppreview(handles.vidobj)
</pre>
</body>
</html>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-12204594019740189752015-11-23T09:30:00.001-08:002016-08-29T13:31:15.715-07:00GUI de Matlab para encontrar el punto de corte de dos funciones.<html>
<head>
<script src="http://latex.codecogs.com/latexit.js" type="text/javascript"></script>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
</head>
<body>
Dadas dos funciones, vamos a encontrar el punto de corte a través de una GUI de Matlab. La interfaz gráfica genera ambas funciones al presionar un botón. Luego, se calcula el punto de corte, se asigna su coordenada a un cuadro de texto estático. La siguiente gráfica muestra el entorno de esta GUI.
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTnW7X51Cs6lh0MbkuYTIgMlKltTP1quR7mGYytY9BuzfbEOfTqetwh3FfkwZdcORS-e_5DHo_x6u7AXwufFS07dQ2Grr3xtalkLP9huO1TcvK3Ww2zqQySn-V9VtCbOsXgjFcfi5_42g/s1600/gui_corte.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTnW7X51Cs6lh0MbkuYTIgMlKltTP1quR7mGYytY9BuzfbEOfTqetwh3FfkwZdcORS-e_5DHo_x6u7AXwufFS07dQ2Grr3xtalkLP9huO1TcvK3Ww2zqQySn-V9VtCbOsXgjFcfi5_42g/s320/gui_corte.png" /></a></div>
Programamos que el segundo botón esté desactivado cuando inicia a correr el programa. Esto lo hacemos en la parte correspondiente del archivo .m <i>OpeningFcn</i>.
<pre class="prettyprint lang-matlab linenums">
% --- Executes just before corte_graficas is made visible.
function corte_graficas_OpeningFcn(hObject, eventdata, handles, varargin)
set(handles.pushbutton2,'Enable','off')
handles.output = hObject;
guidata(hObject, handles);
</pre>
El código que se ejecuta el presionar el primer botón se muestra a continuación. Se generan dos funciones y se colocan sus valores en <i>handles</i> para poder exportar estos valores a otra función del archivo .m.
<pre class="prettyprint lang-matlab linenums">
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
x = 0:0.01:10;
y1 = x .^2 + 2;
y2 = x .^3 ;
handles.x=x;
handles.y1=y1;
handles.y2=y2;
handles.axes1;
plot(x, y1, x, y2);
ylim([0,10])
set(handles.pushbutton2,'Enable','on')
guidata(hObject, handles);
</pre>
Finalmente, el botón etiquetado como <b>Corte</b> ejecuta el código que <a href="http://stackoverflow.com/questions/16384516/show-the-intersection-of-two-curves">encuentra el punto de corte de las dos gráficas</a> y presenta la coordenada en el cuadro estático de texto.
<pre class="prettyprint lang-matlab linenums">
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
idx = find(handles.y1 - handles.y2 < eps, 1); %// Index of coordinate in array
px = handles.x(idx);
py = handles.y1(idx);
set(handles.text1,'String',['x= ',num2str(px),' y= ',num2str(py)])
handles.axes1;
hold on
plot(px, py, 'ro', 'MarkerSize', 18)
hold off
</pre>
</body>
</html>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-43565806975967555312015-09-02T10:29:00.000-07:002016-08-29T14:07:13.076-07:00Cosenoidal con varias fases en Matlab.<html>
<head>
<script src="http://latex.codecogs.com/latexit.js" type="text/javascript"></script>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
</head>
<body>
Graficar en Matlab la señal <span lang="latex">z\left( t \right) = 8\cos \left( {2\pi t + \theta } \right)</span> para valores de <span lang="latex">\theta = \left[ { - {\pi \over 2}, - \pi , - {{3\pi } \over 2}} \right]</span> en el intervalo <span lang="latex">0 \le t \le 8</span>.
<pre class="prettyprint lang-matlab linenums">
t=-1:1/100:1;
cc=['r','g','b'];
w0=2*pi;
desv_tmp=zeros(1,3);
for k=1:3
theta=[-pi/2,-pi,-1.5*pi];
desv_tmp(k)=theta(k)/w0;
z=8*cos(2*pi*t + theta(k));
plot(t,z,'LineWidth',2,'Color',cc(k))
hold on
grid on
end
hold off
</pre>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHgrBcroLnOY4BIP6Bt2Ryd3ZK1hmlC6qzzZa-gYIe8tK0GyGIDnD2c8hV5lx27dFjnhxXL7rdwPVwFWb5C7Wr8mo_4Ukbc5qPRKUDwkkHiRPADSxa3dW-cvlG9QZSaxzh9ctoXY9N_IQ/s1600/cos_fases_matlab.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHgrBcroLnOY4BIP6Bt2Ryd3ZK1hmlC6qzzZa-gYIe8tK0GyGIDnD2c8hV5lx27dFjnhxXL7rdwPVwFWb5C7Wr8mo_4Ukbc5qPRKUDwkkHiRPADSxa3dW-cvlG9QZSaxzh9ctoXY9N_IQ/s400/cos_fases_matlab.png" width="400" height="299" /></a></div>
</body>
</html>
Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-3923647708936260562015-09-02T09:54:00.000-07:002016-08-29T13:59:57.000-07:00Gráfica del seno y coseno con la identidad de Euler en Matlab.<html>
<head>
<script src="http://latex.codecogs.com/latexit.js" type="text/javascript"></script>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
</head>
<body>
Graficar en Matlab las siguientes señales:
<div lang="latex">x\left( t \right) = {e^{j4\pi t}} + {e^{ - j4\pi t}}</div>
<div lang="latex">y\left( t \right) = {{\left( {{e^{j4\pi t}} - {e^{ - j4\pi t}}} \right)} \over j}</div>
<pre class="prettyprint lang-matlab linenums">
t=-1:1/100:1;
s1=2*cos(4*pi*t);
s2=2*sin(4*pi*t);
subplot(2,1,1)
plot(t,s1,'LineWidth',2),grid on
subplot(2,1,2)
plot(t,s2,'LineWidth',2),grid on
</pre>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjENAT4xhnMfP4fDvFdVgsoOvPcqT_4DtgQEa1tuzqvbcqiJRgJHtqM4y-iszjRdHZAj6pSwmMiMj5_tEUqBpxUdZZT4VA8FrFimYSwLI_vefWfRwBUwupyb9WGNz38xc0nILCKLGz6WSk/s1600/seno_coseno_matlab.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjENAT4xhnMfP4fDvFdVgsoOvPcqT_4DtgQEa1tuzqvbcqiJRgJHtqM4y-iszjRdHZAj6pSwmMiMj5_tEUqBpxUdZZT4VA8FrFimYSwLI_vefWfRwBUwupyb9WGNz38xc0nILCKLGz6WSk/s400/seno_coseno_matlab.png" width="400" height="299" /></a></div>
</body>
</html>
Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-39995010811889973232015-08-28T15:23:00.002-07:002016-08-29T16:04:37.209-07:00Errata del libro Señales y Sistemas de Oppenheim.<span style="font-family: consolas;"><span style="line-height: 22.08px; white-space: pre-wrap;"><div>
<ul>
<li><span style="line-height: 22.08px;">Ecuación 1.39 es exp(-j0.5t) (página 20).</span></li>
<li><span style="line-height: 22.08px;">Ecuación 1.123 es x[n].</span></li>
<li><span style="line-height: 22.08px;">Ecuación 2.14 (página 86).</span></li>
<li><span style="line-height: 22.08px;">Ecuación 2.21 (página 89).</span></li>
<li><span style="line-height: 22.08px;">Ecuación 2.30 el h lleva sombrero (página 96).</span></li>
<li><span style="line-height: 22.08px;">Ecuación 3.61 falta 't' en el exponente.</span></li>
<li><span style="line-height: 22.08px;">Ecuación 3.124. El argumentos de H es jkwo. No con la exponencial.</span></li>
<li><span style="line-height: 22.08px;">Problema 3.8. La señal x(t) es real e impar.</span></li>
<li><span style="line-height: 22.08px;">Página 305. Debe ser mayúscula la x.</span></li>
<li><span style="line-height: 22.08px;">Página 310, ejemplo 4.13: la última ecuación es -1, no -2.</span></li>
<li><span style="line-height: 22.08px;">Ecuación 4.45 (página 313) fata 1 sobre 2Pi.</span></li>
<li><span style="line-height: 22.08px;">Ec 4.49 exponente w0 falta.</span></li>
<li><span style="line-height: 22.08px;">Luego de la ecuación 4.83 el exponente de la segunda exponencial</span></li>
<li><span style="line-height: 22.08px;">Ejemplo 5.2. El menos de la seg exponencial</span></li>
<li><span style="line-height: 22.08px;">Ejemplo 5.7 Entre paréntesis va: y otros múltiplos impares de Pi.</span></li>
<li><span style="line-height: 22.08px;">Ecuación 5.47 (página 380) el límite inferior es -Inf.</span></li>
<li><span style="line-height: 22.08px;">Ejemplo 5.9. Para 0, “si n es impar”.</span></li>
<li><span style="line-height: 22.08px;">Figura 5.17. No es omega 0, es omega c.</span></li>
<li><span style="line-height: 22.08px;">Ecuación 9.90 es aR. </span></li>
<li><span style="line-height: 22.08px;">Figura 9.24 es aR (ver etiqueta también), no R/a.</span></li>
<li><span style="line-height: 22.08px;">Página 687, luego de 9.94 “...poles at s=-1+-j3”.</span></li>
<li><span style="line-height: 22.08px;">Ecuación 7.18 es Xc mayúscula.</span></li>
<li><span style="line-height: 22.08px;">Página 916, ecuación A.53 no es A12, es A21.</span></li>
</ul>
</div>
</span></span>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-74839327386569504732015-08-28T15:21:00.001-07:002016-08-29T14:22:22.125-07:00Modulación AM.<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<pre class="prettyprint lang-python linenums">
#AM modulation
# Funcion SINC
import numpy as np
import pylab as plt
from scipy.fftpack import fft
N = 500 # number of sample points
dt = 1. / 1000 # sample spacing
npp=9
nN=N*npp
t = np.linspace(-N*dt, N*dt, nN)
y=np.sinc(150*t)*np.cos(2*np.pi*400*t)
#y=np.abs(np.sinc(t))
plt.figure(1)
plt.plot(t,y, linewidth=2)
plt.grid(True), plt.xlabel('Tiempo')
plt.title(u'x(t)=sinc(150t)*cos(2 $\pi$ (400)t)')
plt.xlim([-6./200,6./200])
# FFT
yf = fft(y)
tf = npp*np.linspace(-1./(4.*dt), 1./(4.*dt), nN)
spectrum = 1./nN * np.concatenate([np.abs(yf[nN/2:nN]), np.abs(yf[0:nN/2])])
#figure1 = plt.figure(4, (10, 5))
plt.figure(2)
plt.plot(tf, spectrum, linewidth=2)
plt.grid()
plt.xlim([-700,700])
plt.title(u'Espectro de magnitud |X(j$\omega$)|')
plt.xlabel('Frecuencia [Hz]')
plt.ylabel('Magnitud |X(j$\omega$)|')
</pre>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicIjXfqqHj5uex5rRHLd3RKVm2iAgiaAkM5zLdvfjl2S2uT6BhyBWjwsPO0u0rjitdGWiKXEyGPJnI9zfEcFxbFnNXhyphenhyphenrPVyUdSup2MYeHigLqzxsE9B5Q_ylXO_q_eCK-5kQA7gOzkfA/s1600/am_py_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicIjXfqqHj5uex5rRHLd3RKVm2iAgiaAkM5zLdvfjl2S2uT6BhyBWjwsPO0u0rjitdGWiKXEyGPJnI9zfEcFxbFnNXhyphenhyphenrPVyUdSup2MYeHigLqzxsE9B5Q_ylXO_q_eCK-5kQA7gOzkfA/s400/am_py_1.png" width="400" height="302" /></a></div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipTVyLJoNPOeRMNn_g1a7JP8DuxV6NughEknjn0onIzNpEmhSkn6fHm5c8QI-OqNvSqkXm2Ns69cxJGqazI7rJpTEEoqwrBxqYQJ14DAfmhdjgJWvMDptJJd4yp964-1wWyJ9lKCyK-3Q/s1600/am_py_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipTVyLJoNPOeRMNn_g1a7JP8DuxV6NughEknjn0onIzNpEmhSkn6fHm5c8QI-OqNvSqkXm2Ns69cxJGqazI7rJpTEEoqwrBxqYQJ14DAfmhdjgJWvMDptJJd4yp964-1wWyJ9lKCyK-3Q/s400/am_py_2.png" width="400" height="302" /></a></div>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-85542884846275488622015-08-28T15:20:00.001-07:002016-08-29T14:33:09.500-07:00Transformada de Fourier de la función Sinc.<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<pre class="prettyprint lang-python linenums">
import numpy as np
import pylab as plt
from scipy.fftpack import fft
N = 500 # number of sample points
dt = 1. / 1000 # sample spacing
npp=3
nN=N*npp
t = np.linspace(-N*dt, N*dt, nN)
y=np.sinc(200*t)
#y=np.abs(np.sinc(t))
plt.figure(1)
plt.plot(t,y)
plt.grid(True), plt.xlabel('Tiempo')
plt.title(u'Sinc(200t)')
plt.xlim([-6./200,6./200])
# FFT
yf = fft(y)
tf = npp*np.linspace(-1./(4.*dt), 1./(4.*dt), nN)
spectrum = 1./nN * np.concatenate([np.abs(yf[nN/2:nN]), np.abs(yf[0:nN/2])])
#figure1 = plt.figure(4, (10, 5))
plt.figure(2)
plt.plot(tf, spectrum, '-')
plt.grid()
plt.xlim([-300,300])
plt.title(u'Espectro de magnitud |X(j$\omega$)|')
plt.xlabel('Frecuencia [Hz]')
plt.ylabel('Magnitud |X(j$\omega$)|')
</pre>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmbXgYF3ye12lUm4aJwo5yzuKNT3ph4twMnVWXq60qvbjAqoLlM5TNgtcjXgM3jpdROa-2_XFQqAPCBZK4iOYZ4ZEVFISNZE6-ET6iLqwXeM_gNOq2m-FqWwaM7VDhu3hyKzH8tNqVu8k/s1600/sinc_py1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmbXgYF3ye12lUm4aJwo5yzuKNT3ph4twMnVWXq60qvbjAqoLlM5TNgtcjXgM3jpdROa-2_XFQqAPCBZK4iOYZ4ZEVFISNZE6-ET6iLqwXeM_gNOq2m-FqWwaM7VDhu3hyKzH8tNqVu8k/s400/sinc_py1.png" width="400" height="302" /></a></div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8U5fhCL1au8a6yKbU7ymqM4Whut3l0O_kezvl3g2uVXXtY4l6dvqqNumTvlQ-kL6VZIs8wBcWB0MT99QABODkLXXIS8aWdU2xV-ejLkgpxapSnmU_fvZ2dDB6YKTjCJXdewGBEVpvGdE/s1600/sinc_py2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8U5fhCL1au8a6yKbU7ymqM4Whut3l0O_kezvl3g2uVXXtY4l6dvqqNumTvlQ-kL6VZIs8wBcWB0MT99QABODkLXXIS8aWdU2xV-ejLkgpxapSnmU_fvZ2dDB6YKTjCJXdewGBEVpvGdE/s400/sinc_py2.png" width="400" height="302" /></a></div>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-71356871611041819202015-08-28T15:17:00.003-07:002016-08-29T14:36:12.649-07:00Espectro unilateral de un suma de senoides en Python.<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<pre class="prettyprint lang-python linenums">
import numpy as np
#from scipy import signal
from scipy.fftpack import fft
import matplotlib.pyplot as plt
N = 1000 # number of sample points
dt = 1. / 500 # sample spacing
frequency1 = 50.
frequency2 = 150.
nN=N*4
t = np.linspace(0.0, N*dt, nN)
s1 = 0.8*np.sin(2*np.pi * frequency1 * t)
s2 = 0.4* np.sin(2*np.pi * frequency2 * t)
y = s1 + s2
plt.figure(1)
plt.plot(t, s1)
plt.grid()
plt.title('Senoide de '+str(frequency1)+' Hz')
plt.ylabel('Amplitud')
plt.xlabel('Tiempo [s]')
plt.axis([0, 8/frequency2, -1.5, 1.5])
plt.figure(2)
plt.plot(t, s2)
plt.grid()
plt.title('Senoide de '+str(frequency2)+' Hz')
plt.ylabel('Amplitud')
plt.xlabel('Tiempo [s]')
plt.axis([0, 8/frequency2, -1.5, 1.5])
plt.figure(3)
plt.plot(t, s1+s2)
plt.grid()
plt.title('Suma de senoides de '+str(frequency1)+' Hz'+' y '+str(frequency2)+' Hz')
plt.ylabel('Amplitud')
plt.xlabel('Tiempo [s]')
plt.axis([0, 8/frequency2, -1.5, 1.5])
# FFT
yf = fft(y)
tf = np.linspace(.0, 1./(2.*dt), N/2)
spectrum = 2./nN * np.abs(yf[0:N/2])
#figure1 = plt.figure(4, (10, 5))
plt.figure(4)
plt.plot(tf, spectrum, '-')
plt.grid()
plt.title(u'Espectro de magnitud |X(j$\omega$)|')
plt.xlabel('Frequencia [Hz]')
plt.ylabel('Magnitud |X(j$\omega$)|')
</pre>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYYipx4rXwQQutZ2kSWGwfTPm2sRoCSBPZzCZh_Fszc3Q_Bsk-Ua5TlpoR78SUgW0K3mukQ5oISnkNEiMz7R7Ldwz4Yv55I7Dk46G3DLsuP-WFnvX4Mc70fuGevfNqr-JrhJyXdbsdlfE/s1600/sum_sen_py1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYYipx4rXwQQutZ2kSWGwfTPm2sRoCSBPZzCZh_Fszc3Q_Bsk-Ua5TlpoR78SUgW0K3mukQ5oISnkNEiMz7R7Ldwz4Yv55I7Dk46G3DLsuP-WFnvX4Mc70fuGevfNqr-JrhJyXdbsdlfE/s400/sum_sen_py1.png" width="400" height="302" /></a></div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtL1r8NpD2XprLBy0PlRUByd1X2ezbmo9WJ216nHBtPvcWj2exMDZ6-q3EgAD7Zphbz_xiYnUYnJW1t_6jkwLpkXRsluxJfuAxOh6xkglajVcPLxwlktIUQEfDLv4ohjU1RzvlTkuFsCY/s1600/sum_sen_py2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtL1r8NpD2XprLBy0PlRUByd1X2ezbmo9WJ216nHBtPvcWj2exMDZ6-q3EgAD7Zphbz_xiYnUYnJW1t_6jkwLpkXRsluxJfuAxOh6xkglajVcPLxwlktIUQEfDLv4ohjU1RzvlTkuFsCY/s400/sum_sen_py2.png" width="400" height="302" /></a></div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtmGeLEJmcrF8pbGfFLjlXnoE2L6yy4MtRnCd0gYzi1iTzOvIUV8wn-VuBLGM2eIz7k4TAGDt_MCY-XaaQD5Z4rW37KLBxSjxqLBh1SFcxuUvn-ep7Pw8-8rdNnAscBmC8ZJ8coLsm0Qs/s1600/sum_sen_py3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtmGeLEJmcrF8pbGfFLjlXnoE2L6yy4MtRnCd0gYzi1iTzOvIUV8wn-VuBLGM2eIz7k4TAGDt_MCY-XaaQD5Z4rW37KLBxSjxqLBh1SFcxuUvn-ep7Pw8-8rdNnAscBmC8ZJ8coLsm0Qs/s400/sum_sen_py3.png" width="400" height="302" /></a></div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNFzMXvDUC4WeqfZ_udYDoPc1XHsn91cKjIgUQwCkugjUaoMK0zOxKev4PCJQNnLj6EjZNJmst7j9PEzVc6k9DkQ26g0RJO6Gw0_yzmChAyCLKht6wSBoZT_cRJd1o38hpIquRQi8O8m0/s1600/sum_sen_py4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNFzMXvDUC4WeqfZ_udYDoPc1XHsn91cKjIgUQwCkugjUaoMK0zOxKev4PCJQNnLj6EjZNJmst7j9PEzVc6k9DkQ26g0RJO6Gw0_yzmChAyCLKht6wSBoZT_cRJd1o38hpIquRQi8O8m0/s400/sum_sen_py4.png" width="400" height="302" /></a></div>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-74905311095891580172015-08-28T15:15:00.003-07:002016-08-29T13:32:05.175-07:00Espectro bilateral de un suma de senoides en Python.<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<pre class="prettyprint lang-python linenums">
import numpy as np
#from scipy import signal
from scipy.fftpack import fft,fftshift
import matplotlib.pyplot as plt
N = 1000 # number of sample points
Fs=500.
dt = 1. / Fs # sample spacing
frequency1 = 50.
frequency2 = 150.
npp=4
nN=N*npp
t = np.linspace(0.0, N*dt, nN)
s1 = 0.8*np.sin(2*np.pi * frequency1 * t)
s2 = 0.4* np.sin(2*np.pi * frequency2 * t)
y = s1 + s2
plt.figure(1)
plt.plot(t, s1)
plt.grid()
plt.title('Senoide de '+str(frequency1)+' Hz')
plt.ylabel('Amplitud')
plt.xlabel('Tiempo [s]')
plt.axis([0, 8/frequency2, -1.5, 1.5])
plt.figure(2)
plt.plot(t, s2)
plt.grid()
plt.title('Senoide de '+str(frequency2)+' Hz')
plt.ylabel('Amplitud')
plt.xlabel('Tiempo [s]')
plt.axis([0, 8/frequency2, -1.5, 1.5])
plt.figure(3)
plt.plot(t, s1+s2)
plt.grid()
plt.title('Suma de senoides de '+str(frequency1)+' Hz'+' y '+str(frequency2)+' Hz')
plt.ylabel('Amplitud')
plt.xlabel('Tiempo [s]')
plt.axis([0, 8/frequency2, -1.5, 1.5])
# FFT
yf = fft(y)
tf = npp*np.linspace( -1./(2.*dt), 1./(2.*dt), nN)
spectrum = 2./nN * np.abs(fftshift(yf))
#figure1 = plt.figure(4, (10, 5))
plt.figure(4)
plt.plot(tf, spectrum, '-')
plt.grid()
plt.title(u'Espectro de magnitud |X(j$\omega$)|')
plt.xlabel('Frequencia [Hz]')
plt.ylabel('Magnitud |X(j$\omega$)|')
#plt.axis([-200, 200, 0., 1.5])
</pre>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-50917679381596844052015-08-28T15:14:00.002-07:002016-08-29T15:18:48.487-07:00Coeficientes de la serie de Fourier conforme T tiende al infinito.<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<pre class="prettyprint lang-python linenums">
import numpy as np
import pylab as pl
T1=1
T=4*T1
w0=2*np.pi/T
k=np.arange(-40*w0,40*w0,w0)
ak=(2.0*T1)*np.sinc(k)
pl.subplot(4,1,1)
pl.stem(k,ak*T)
pl.hold(True)
ke=np.arange(-40*w0,40*w0,w0/10)
ake=(2.0*T1)*np.sinc(ke)
pl.plot(ke,ake*T,'r--')
pl.hold(False)
pl.grid(True)
pl.xlim([-15,15])
T=8*T1
w0=2*np.pi/T
k=np.arange(-40*w0,40*w0,w0)
ak=(2.0*T1)*np.sinc(k)
pl.subplot(4,1,2)
pl.stem(k,ak*T)
pl.hold(True)
ke=np.arange(-40*w0,40*w0,w0/10)
ake=(2.0*T1)*np.sinc(ke)
pl.plot(ke,ake*T,'r--')
pl.hold(False)
pl.grid(True)
pl.xlim([-15,15])
T=16*T1
w0=2*np.pi/T
k=np.arange(-40*w0,40*w0,w0)
ak=(2.0*T1)*np.sinc(k)
pl.subplot(4,1,3)
pl.stem(k,ak*T)
pl.hold(True)
ke=np.arange(-40*w0,40*w0,w0/10)
ake=(2.0*T1)*np.sinc(ke)
pl.plot(ke,ake*T,'r--')
pl.hold(False)
pl.grid(True)
pl.xlim([-15,15])
T=32*T1
w0=2*np.pi/T
k=np.arange(-80*w0,80*w0,w0)
ak=(2.0*T1)*np.sinc(k)
pl.subplot(4,1,4)
pl.stem(k,ak*T)
pl.hold(True)
ke=np.arange(-40*w0,40*w0,w0/10)
ake=(2.0*T1)*np.sinc(ke)
pl.plot(ke,ake*T,'r--')
pl.hold(False)
pl.grid(True)
pl.xlim([-15,15])
</pre>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4Srp83wxZrzDOrith-C1MruS8steMTk7D53DD1rg22wrw3V2ZL68HpHG5CwR3LchS2lh_jrMmNTTU8lRCUgwZrB-A7fumnMEduC3SsOkD1F4sbKspXCvbRdqQWqT-QUOZxOyG7dGodkk/s1600/py_T_inf.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4Srp83wxZrzDOrith-C1MruS8steMTk7D53DD1rg22wrw3V2ZL68HpHG5CwR3LchS2lh_jrMmNTTU8lRCUgwZrB-A7fumnMEduC3SsOkD1F4sbKspXCvbRdqQWqT-QUOZxOyG7dGodkk/s640/py_T_inf.png" width="640" height="314" /></a></div>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-85756988701109367892015-08-28T15:13:00.001-07:002016-08-29T15:21:04.787-07:00Función sinc en Python.<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<pre class="prettyprint lang-python linenums">
# Funcion SINC
import numpy as np
import pylab as pl
t=np.linspace(-10,10,1000)
s=np.sinc(t)
s_mod=np.abs(np.sinc(t))
pl.figure(1)
pl.plot(t,s)
pl.grid(True), pl.xlabel('Tiempo')
pl.figure(2)
pl.plot(t,s_mod)
pl.grid(True), pl.xlabel('Tiempo')
</pre>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGhezDsfpbkj8OFkmAbfQke4CpfrxhDhpTAE6KW4rf22VNglWPQahwNUxI9sFfgqcyqi51y61X5fL7R4ajfEgUWkQ9MTouUIRk867xgzJZSaDuQOd4A1PCvUFYmdVO12p4YBUHQ0GHvCk/s1600/sinc_abs_py.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGhezDsfpbkj8OFkmAbfQke4CpfrxhDhpTAE6KW4rf22VNglWPQahwNUxI9sFfgqcyqi51y61X5fL7R4ajfEgUWkQ9MTouUIRk867xgzJZSaDuQOd4A1PCvUFYmdVO12p4YBUHQ0GHvCk/s400/sinc_abs_py.png" width="400" height="302" /></a></div>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-70640733872135851692015-08-28T15:11:00.002-07:002016-08-29T15:22:08.836-07:00Serie de Fourier de una onda triangular.<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<pre class="prettyprint lang-python linenums">
import pylab
import numpy as np
#Reconstruccion
A=1.
a0=1./2
t=np.linspace(-3,3,10000)
s_per=0
for k in range(-30,30):
#ak=((-1)^k-1)*A/(np.pi^2*k^2)
if k!=0:
s_per=s_per+((-1)**k-1)*A/(np.pi**2*k**2)*np.exp(1j*k*2*np.pi*t)
s_per=s_per+a0
pylab.plot(t,s_per), pylab.show()
pylab.grid(True)
</pre>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQM9LSmxjGOXrvMvRqz7ICzx5Yfcc889_v28Zu_On3V_yx-5cZvEETOl4WqoWtyqel0sFRCQp1w426YVPhSEJZyTjaZIb_mHbUSM9U8ctmW-FuqxMzWxGOt5MTkKx46ovVknu23r5z_As/s1600/ond_tri_py.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQM9LSmxjGOXrvMvRqz7ICzx5Yfcc889_v28Zu_On3V_yx-5cZvEETOl4WqoWtyqel0sFRCQp1w426YVPhSEJZyTjaZIb_mHbUSM9U8ctmW-FuqxMzWxGOt5MTkKx46ovVknu23r5z_As/s400/ond_tri_py.png" width="400" height="302" /></a></div>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-28638286889481518512015-08-28T15:10:00.002-07:002016-08-29T13:51:31.287-07:00Serie de Fourier de una onda cuadrada.<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<pre class="prettyprint lang-python linenums">
import pylab
import numpy as np
#Con SINC
k=np.arange(-30,30)
ak=(1/8.0)*np.sinc(k/8.0)*np.exp(-1j*k*np.pi/8.0)
m=np.abs(ak)
f=np.angle(ak)
#pylab.figure(2)
#pylab.stem(k,m,markerfmt=" ")
#pylab.show()
#Reconstruccion
t=np.linspace(-2,2,10000)
s_per=0
for k in range(-30,30):
#print s_per
s_per=s_per+(1/8.0)*np.sinc(k/8.0)*np.exp(-1j*k*np.pi/8.0)*np.exp(1j*k*2*np.pi*t)
pylab.plot(t,s_per), pylab.show()
</pre>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDq_ocfnYzH1WfEU0I2t9SjSEJxiRlpyUul0lEUpuARpRVgVMW-fdauLChP-xftvmSRadLQE-49LAHXbpSWS6ZkI3zLg1RQxP0AmILlY1-XSFU6IQ-FDEOrWQTr259CQ6NuCWtI5pK9Hg/s1600/Serie_Fourier_Onda_cuadrada_python.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDq_ocfnYzH1WfEU0I2t9SjSEJxiRlpyUul0lEUpuARpRVgVMW-fdauLChP-xftvmSRadLQE-49LAHXbpSWS6ZkI3zLg1RQxP0AmILlY1-XSFU6IQ-FDEOrWQTr259CQ6NuCWtI5pK9Hg/s400/Serie_Fourier_Onda_cuadrada_python.png" width="400" height="302" /></a></div>
Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com0tag:blogger.com,1999:blog-5358587574534994033.post-24630178691355362742015-08-28T15:05:00.004-07:002016-08-29T14:05:51.983-07:00Convolución continua con Python.<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<pre class="prettyprint lang-python linenums">
#By Mark Wickert from Signals and Systems For Dummies
def expo_conv(t,A,alpha):
import numpy as np
y = np.zeros(len(t))
for k, tk in enumerate(t):
if tk >= 0:
y[k] = A/alpha*(1 - np.exp(-alpha*tk))
return y
import numpy as np
import pylab as pl
import ssd
t = np.arange(-4,14,.01)
xc2 = ssd.step(t)
hc2 = ssd.step(t)*np.exp(-1*t)
yc2_num,tyc2 = ssd.conv_integral(xc2,t,hc2,t,('r','r'))
#pl.subplot(211)
pl.plot(tyc2,yc2_num,linewidth=2)
pl.grid(True)
pl.xlabel('Tiempo (t)')
pl.title('y(t)=x(t)*h(t)')
pl.axis([-8,10,-0.5,1.5])
#pl.subplot(212)
#pl.plot(t,expo_conv(t,1,1))
</pre>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtSpZB0hdxarZMmMN0kWXqtMKnliCm_0CDmABhGp9bKHNmo1nTdXLxGzCOHLHkrHaFDkSYnN9Aw7FvpNFqzeBfe9NDk68troUavAjNf8VdeHBh0ZVjnhDvDLMgfWFpGrfdqOb99lBIkkQ/s1600/y_conv_cont_py.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtSpZB0hdxarZMmMN0kWXqtMKnliCm_0CDmABhGp9bKHNmo1nTdXLxGzCOHLHkrHaFDkSYnN9Aw7FvpNFqzeBfe9NDk68troUavAjNf8VdeHBh0ZVjnhDvDLMgfWFpGrfdqOb99lBIkkQ/s400/y_conv_cont_py.png" width="400" height="302" /></a></div>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com4tag:blogger.com,1999:blog-5358587574534994033.post-22798271659626473072015-08-28T15:04:00.001-07:002016-08-29T13:55:30.817-07:00Convolución discreta con Python.<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<pre class="prettyprint lang-python linenums">
#By Mark Wickert from Signals and Systems For Dummies
import numpy as np
import pylab as pl
import ssd
n=np.arange(-4,6)
xd1=2*ssd.drect(n,4)
hd1=1.5*ssd.dimpulse(n)-0.5*ssd.drect(n+1,3)
#hd1=-0.5*ssd.dimpulse(n+1)+1*ssd.dimpulse(n)-0.5*ssd.dimpulse(n-1)
yd1_num,nd1=ssd.conv_sum(xd1,n,hd1,n)
#pl.subplot(1,3,1)
pl.figure(1)
pl.stem(n,xd1)
pl.title('x[n]'), pl.axis([-4,5,-1,3]),pl.grid(True)
#pl.subplot(1,3,2)
pl.figure(2)
pl.stem(n,hd1),pl.grid(True)
pl.title('h[n]')
#pl.subplot(1,3,3)
pl.figure(3)
pl.stem(nd1,yd1_num), pl.axis([-4,5,-2,2]),pl.grid(True)
pl.title('y[n]=x[n]*h[n]')
</pre>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMY7wAN4wKflegGqx4SYqULftKMIti9h9QZ-0sMoP5szq09pbMJQeTw2Lzid6HOnQULdghPCQFmnYgwrkLY8LP9noN39i1gPJ4WiyVDrfyrSk2lgkgn6n-LQkDoguKOLN39-ETsRQcYfI/s1600/x_python.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMY7wAN4wKflegGqx4SYqULftKMIti9h9QZ-0sMoP5szq09pbMJQeTw2Lzid6HOnQULdghPCQFmnYgwrkLY8LP9noN39i1gPJ4WiyVDrfyrSk2lgkgn6n-LQkDoguKOLN39-ETsRQcYfI/s400/x_python.png" width="400" height="302" /></a></div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNSLpefDF-zY-nz217Ns9hqZsoZ-9nK4cllkkCTo2H17BUwQrqvjX0wjuC7RszK5hpfskbxkEx3a7ZTUFP741i_uyqgAAEZ52K8w1SaCB6nHcQsCp2D6OHYC4O4CQxyAgimeCyD0huSYM/s1600/h_python.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNSLpefDF-zY-nz217Ns9hqZsoZ-9nK4cllkkCTo2H17BUwQrqvjX0wjuC7RszK5hpfskbxkEx3a7ZTUFP741i_uyqgAAEZ52K8w1SaCB6nHcQsCp2D6OHYC4O4CQxyAgimeCyD0huSYM/s400/h_python.png" width="400" height="302" /></a></div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhujiyPOVIquSti24Fk-dw-HxQaDzPH8_Rr5pyiwHKmQdz-gFS6x9WKulSwtbd3RixxwEHBpRteuhYfwkCNfcNaRo34kPf2DnBpFeblGLFFbbJw5RfWqKa4uiy24XSkpWT7CdRDDewGZvs/s1600/y_python.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhujiyPOVIquSti24Fk-dw-HxQaDzPH8_Rr5pyiwHKmQdz-gFS6x9WKulSwtbd3RixxwEHBpRteuhYfwkCNfcNaRo34kPf2DnBpFeblGLFFbbJw5RfWqKa4uiy24XSkpWT7CdRDDewGZvs/s400/y_python.png" width="400" height="302" /></a></div>Diego Barragán Guerrerohttp://www.blogger.com/profile/12570514890187124364noreply@blogger.com6