<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="es">
    <title>Nezzontli - MATLAB</title>
    <subtitle>Bitácora personal de Alejandro B.E.: tecnología, física, sistemas resilientes y fotografía analógica.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://nezzontli.xyz/es/tags/matlab/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://nezzontli.xyz"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-03-15T00:00:00+00:00</updated>
    <id>https://nezzontli.xyz/es/tags/matlab/atom.xml</id>
    <entry xml:lang="es">
        <title>Reconstrucción de Sonido con Láser y Fotosensor: De la Teoría al Código</title>
        <published>2026-03-15T00:00:00+00:00</published>
        <updated>2026-03-15T00:00:00+00:00</updated>
        
        <author>
          <name>
            B.E. Alejandro
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://nezzontli.xyz/es/blog/matlab/"/>
        <id>https://nezzontli.xyz/es/blog/matlab/</id>
        
        <content type="html" xml:base="https://nezzontli.xyz/es/blog/matlab/">&lt;h2 id=&quot;el-problema-puede-un-rayo-de-luz-transportar-sonido&quot;&gt;El Problema: ¿Puede un Rayo de Luz Transportar Sonido?&lt;&#x2F;h2&gt;
&lt;p&gt;La idea surgió de una pregunta aparentemente simple en clase de física: si el sonido es una onda mecánica que vibra el aire, ¿podría esa vibración modular un haz de luz y recuperarse después?&lt;&#x2F;p&gt;
&lt;p&gt;La respuesta es sí, y el principio es elegante. El sonido dentro de una caja insonorizada hace vibrar un panel de vidrio. Un láser de 650 nm apunta al vidrio desde afuera; el reflejo modulado por las vibraciones es capturado por un fotodiodo BPW34. La corriente fotoeléctrica resultante pasa por un amplificador de transimpedancia (TIA LM358) que la convierte en voltaje, luego por un MAX9814 con control de ganancia automático (AGC), y finalmente llega al jack de micrófono de la PC donde MATLAB la digitaliza y reconstruye el audio original:&lt;&#x2F;p&gt;
&lt;p&gt;$$V(t) = A \cdot \sin(2\pi f t) + \eta(t)$$&lt;&#x2F;p&gt;
&lt;p&gt;donde $\eta(t)$ es el ruido introducido por el sistema óptico-electrónico. El reto es precisamente ese: dado que $\eta(t)$ siempre existe, ¿cómo recuperamos la señal $A \cdot \sin(2\pi f t)$ con la mayor fidelidad posible?&lt;&#x2F;p&gt;
&lt;p&gt;Este post documenta la &lt;strong&gt;fase de simulación completa en MATLAB&lt;&#x2F;strong&gt; que valida los algoritmos antes de construir el hardware real.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;fundamentos-teoricos&quot;&gt;Fundamentos Teóricos&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;transformada-de-fourier-fft&quot;&gt;Transformada de Fourier (FFT)&lt;&#x2F;h3&gt;
&lt;p&gt;El teorema de Fourier establece que cualquier señal periódica puede descomponerse como suma de senos y cosenos. La Transformada de Fourier Discreta (DFT) hace esto numéricamente:&lt;&#x2F;p&gt;
&lt;p&gt;$$X[k] = \sum_{n=0}^{N-1} x[n] \cdot e^{-j2\pi kn&#x2F;N}$$&lt;&#x2F;p&gt;
&lt;p&gt;La &lt;strong&gt;FFT&lt;&#x2F;strong&gt; (Fast Fourier Transform) es un algoritmo eficiente para calcular la DFT en $O(N \log N)$ en lugar de $O(N^2)$. Para este proyecto, la FFT cumple dos funciones:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Identificar&lt;&#x2F;strong&gt; qué frecuencias componen la señal capturada&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Filtrar&lt;&#x2F;strong&gt; el ruido eliminando componentes espectrales débiles&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h3 id=&quot;descomposicion-en-valores-singulares-svd&quot;&gt;Descomposición en Valores Singulares (SVD)&lt;&#x2F;h3&gt;
&lt;p&gt;Dado que el proyecto conecta con el tema de &lt;em&gt;espacios vectoriales&lt;&#x2F;em&gt; del semestre, también apliqué SVD para analizar la estructura de cada señal. Dada una matriz de trayectoria $M$ construida a partir de la señal:&lt;&#x2F;p&gt;
&lt;p&gt;$$M = U \cdot \Sigma \cdot V^T$$&lt;&#x2F;p&gt;
&lt;p&gt;Los valores singulares $\sigma_i$ en $\Sigma$ revelan cuántos “modos independientes” necesita la señal para representarse. Una señal simple (tono puro) tiene muy pocos valores singulares grandes; una señal compleja los tiene distribuidos.&lt;&#x2F;p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
	&lt;p&gt;&lt;strong&gt;Conexión con el curso:&lt;&#x2F;strong&gt; El SVD es esencialmente un cambio de base ortogonal. Los vectores columna de $U$ son la nueva base en el espacio de la señal, y los valores singulares son las “coordenadas” de importancia de cada vector base. Exactamente el mismo concepto de base ortonormal que vimos en clase.&lt;&#x2F;p&gt;

&lt;&#x2F;blockquote&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;el-hardware&quot;&gt;El Hardware&lt;&#x2F;h2&gt;
&lt;p&gt;El sistema físico que se simulará y construirá está formado por los siguientes componentes, elegidos por su precisión y bajo ruido:&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Componente&lt;&#x2F;th&gt;&lt;th&gt;Función&lt;&#x2F;th&gt;&lt;th&gt;Parámetro clave&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Láser D18×65mm 650nm 5mW&lt;&#x2F;td&gt;&lt;td&gt;Fuente de luz, punto continuo&lt;&#x2F;td&gt;&lt;td&gt;Enfocable, montado en soporte Neiko ~30°&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;BPW34 (fotodiodo PIN)&lt;&#x2F;td&gt;&lt;td&gt;Luz → corriente&lt;&#x2F;td&gt;&lt;td&gt;R = 0.3 A&#x2F;W @ 650 nm, en tubo negro&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;LM358 (TIA)&lt;&#x2F;td&gt;&lt;td&gt;Corriente → voltaje&lt;&#x2F;td&gt;&lt;td&gt;Rf = 10 kΩ, Cf = 100 pF&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Capacitor C_ac 10 µF&lt;&#x2F;td&gt;&lt;td&gt;Bloqueo de offset DC&lt;&#x2F;td&gt;&lt;td&gt;fc = 1.6 Hz&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;MAX9814 HiLetgo&lt;&#x2F;td&gt;&lt;td&gt;Amplificador AGC&lt;&#x2F;td&gt;&lt;td&gt;Av = 40 dB (GAIN flotante)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Capacitor C_sal 47 µF&lt;&#x2F;td&gt;&lt;td&gt;Bloqueo offset salida&lt;&#x2F;td&gt;&lt;td&gt;fc = 0.34 Hz&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Módulo Jack ShillehTek 3.5mm&lt;&#x2F;td&gt;&lt;td&gt;Interfaz PC&lt;&#x2F;td&gt;&lt;td&gt;Entrada micrófono, breakout TRRS&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;ESP32&lt;&#x2F;td&gt;&lt;td&gt;Fuente de alimentación 5V&lt;&#x2F;td&gt;&lt;td&gt;Pin VIN → rail protoboard&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Soporte Neiko&lt;&#x2F;td&gt;&lt;td&gt;Posicionar láser en ángulo&lt;&#x2F;td&gt;&lt;td&gt;Ajuste ~30° sobre el vidrio&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;La ventaja principal del BPW34 sobre un LDR es su tiempo de respuesta: 20 ns frente a ~1 ms, permitiendo capturar audio hasta 20 kHz sin ninguna degradación por el sensor.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;diagrama-del-circuito&quot;&gt;Diagrama del circuito&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;github.com&#x2F;Richard7987&#x2F;Proyecto-Fisica-2do&#x2F;raw&#x2F;main&#x2F;Imagenes&#x2F;Diagrama%20de%20Circuito%20%E2%80%94%20Microfono%20Laser.png&quot; alt=&quot;Diagrama de circuito completo: BPW34 → TIA LM358 → MAX9814 → Jack PC&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;montaje-experimental&quot;&gt;Montaje experimental&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;github.com&#x2F;Richard7987&#x2F;Proyecto-Fisica-2do&#x2F;raw&#x2F;main&#x2F;Imagenes&#x2F;Simulacion%203D%20%E2%80%94%20Microfono%20Laser.png&quot; alt=&quot;Simulacion 3D animada del montaje experimental completo&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;La escena 3D muestra el montaje completo: caja insonorizada con vidrio vibrante, láser industrial D18×65 mm sobre soporte Neiko apuntando al vidrio en ~30°, BPW34 en tubo negro en el ángulo de reflexión especular, y el circuito completo (ESP32 + LM358 + MAX9814 + módulo jack) en la protoboard. La animación sincroniza la vibración del vidrio con las señales en tiempo real en cada etapa del pipeline.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;metodologia-de-simulacion&quot;&gt;Metodología de Simulación&lt;&#x2F;h2&gt;
&lt;p&gt;Para validar los algoritmos sin hardware, generé cuatro tipos de señal en MATLAB y simulé el proceso completo con el pipeline óptico-electrónico real: generación → modulación óptica → BPW34 → TIA → MAX9814 → filtrado FFT → reconstrucción → validación.&lt;&#x2F;p&gt;
&lt;p&gt;A diferencia de simplemente sumar ruido gaussiano, el modelo simula la cadena física completa:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;matlab&quot; class=&quot;language-matlab z-code&quot;&gt;&lt;code class=&quot;language-matlab&quot; data-lang=&quot;matlab&quot;&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;&lt;span class=&quot;z-keyword z-other z-matlab&quot;&gt;function&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-output z-function z-matlab&quot;&gt;v_out&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-matlab&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-matlab&quot;&gt; &lt;span class=&quot;z-entity z-name z-function z-matlab&quot;&gt;pipeline_sensor&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-input z-function z-matlab&quot;&gt;audio&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-matlab&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-input z-function z-matlab&quot;&gt;P_laser&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-matlab&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-input z-function z-matlab&quot;&gt;mod_depth&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-matlab&quot;&gt;,&lt;&#x2F;span&gt; ...
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;&lt;span class=&quot;z-meta z-function z-parameters z-matlab&quot;&gt;                                 &lt;span class=&quot;z-variable z-parameter z-input z-function z-matlab&quot;&gt;R_bpw34&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-matlab&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-input z-function z-matlab&quot;&gt;Rf_TIA&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-matlab&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-input z-function z-matlab&quot;&gt;Av_MAX&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-matlab&quot;&gt;,&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-input z-function z-matlab&quot;&gt;ruido&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-comment z-line z-percentage z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-matlab&quot;&gt;%&lt;&#x2F;span&gt; 1. Modulacion optica: el vidrio vibrante modula el reflejo
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;P_luz&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;  = &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;P_laser&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; * &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; + &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;mod_depth&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; * &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;audio&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-comment z-line z-percentage z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-matlab&quot;&gt;%&lt;&#x2F;span&gt; 2. BPW34: fotocorriente = responsividad x potencia + shot noise
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;I_foto&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; = &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;R_bpw34&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; * &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;P_luz&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; + &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;ruido&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; * &lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;1e-4&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; * &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-mathematics z-matlab&quot;&gt;randn&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-mathematics z-matlab&quot;&gt;size&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;audio&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-comment z-line z-percentage z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-matlab&quot;&gt;%&lt;&#x2F;span&gt; 3. TIA LM358: I → V, eliminar offset DC (como el capacitor C_ac)
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;V_tia&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;  = &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;I_foto&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; * &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;Rf_TIA&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;V_tia&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;  = &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;V_tia&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; - &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-analysis z-matlab&quot;&gt;mean&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;V_tia&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-comment z-line z-percentage z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-matlab&quot;&gt;%&lt;&#x2F;span&gt; 4. MAX9814: amplificar y saturar (±1.65V)
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;V_max&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;  = &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;Av_MAX&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; * &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;V_tia&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;v_out&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;  = &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-analysis z-matlab&quot;&gt;max&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;-&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;1.65&lt;&#x2F;span&gt;, &lt;span class=&quot;z-keyword z-analysis z-matlab&quot;&gt;min&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;1.65&lt;&#x2F;span&gt;, &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;V_max&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;&lt;span class=&quot;z-keyword z-control z-matlab&quot;&gt;end&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;El ruido del BPW34 (shot noise) es de apenas 0.8% de la señal — notablemente menor que el 5% típico de un LDR, lo que explica los resultados de SNR superiores.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;las-cuatro-senales-de-prueba&quot;&gt;Las Cuatro Señales de Prueba&lt;&#x2F;h3&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Señal&lt;&#x2F;th&gt;&lt;th&gt;Frecuencias&lt;&#x2F;th&gt;&lt;th&gt;Por qué es interesante&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Tono puro&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;1000 Hz&lt;&#x2F;td&gt;&lt;td&gt;Caso base, señal más simple posible&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Acorde Do Mayor&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;262 + 330 + 392 Hz&lt;&#x2F;td&gt;&lt;td&gt;Tres frecuencias simultáneas (Do, Mi, Sol)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Barrido (chirp)&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;100 → 1000 Hz&lt;&#x2F;td&gt;&lt;td&gt;Frecuencia variable en el tiempo&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Señal compleja&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;262·k Hz, k=1..5&lt;&#x2F;td&gt;&lt;td&gt;Serie armónica, simula voz humana&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h3 id=&quot;el-algoritmo-de-reconstruccion&quot;&gt;El Algoritmo de Reconstrucción&lt;&#x2F;h3&gt;
&lt;p&gt;El núcleo del sistema es el filtrado espectral: se aplica una máscara binaria al espectro FFT que conserva solo las componentes que superan el 10% del pico máximo, luego se reconstruye la señal con la IFFT. La clave es mantener la &lt;strong&gt;simetría hermitiana&lt;&#x2F;strong&gt; del espectro para que la IFFT devuelva valores reales:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;matlab&quot; class=&quot;language-matlab z-code&quot;&gt;&lt;code class=&quot;language-matlab&quot; data-lang=&quot;matlab&quot;&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;&lt;span class=&quot;z-keyword z-other z-matlab&quot;&gt;function&lt;&#x2F;span&gt; &lt;span class=&quot;z-variable z-parameter z-output z-function z-matlab&quot;&gt;senial_rec&lt;&#x2F;span&gt; &lt;span class=&quot;z-keyword z-operator z-assignment z-matlab&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-function z-parameters z-matlab&quot;&gt; &lt;span class=&quot;z-entity z-name z-function z-matlab&quot;&gt;reconstruir_por_fft&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable z-parameter z-input z-function z-matlab&quot;&gt;senial_ruidosa&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;N&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;        = &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-mathematics z-matlab&quot;&gt;length&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;senial_ruidosa&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;Y&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;        = &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-analysis z-matlab&quot;&gt;fft&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;senial_ruidosa&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-comment z-line z-percentage z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-matlab&quot;&gt;%&lt;&#x2F;span&gt; Magnitud del espectro unilateral (DC hasta Nyquist inclusive)
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;mag_pos&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;  = &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-analysis z-matlab&quot;&gt;abs&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;Y&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; : &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-mathematics z-matlab&quot;&gt;floor&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;N&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; + &lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;umbral&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;   = &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-analysis z-matlab&quot;&gt;max&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;mag_pos&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; * &lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;0.1&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-comment z-line z-percentage z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-matlab&quot;&gt;%&lt;&#x2F;span&gt; Máscara binaria: 1 donde la señal supera el umbral
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;mascara_pos&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; = &lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type z-matlab&quot;&gt;double&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;mag_pos&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; &amp;gt; &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;umbral&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-comment z-line z-percentage z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-matlab&quot;&gt;%&lt;&#x2F;span&gt; Máscara completa con simetría hermitiana para señal real
&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;mascara&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; = &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-mathematics z-matlab&quot;&gt;zeros&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;N&lt;&#x2F;span&gt;, &lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;mascara&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; : &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-mathematics z-matlab&quot;&gt;floor&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;N&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; + &lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;1&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;   = &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;mascara_pos&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;mascara&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-mathematics z-matlab&quot;&gt;floor&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;N&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;+&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; : &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;N&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;     = &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-mathematics z-matlab&quot;&gt;flipud&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;mascara_pos&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; : &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-mathematics z-matlab&quot;&gt;floor&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;N&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric z-matlab&quot;&gt;2&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;    &lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;senial_rec&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; = &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-mathematics z-matlab&quot;&gt;real&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-analysis z-matlab&quot;&gt;ifft&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-parens z-matlab&quot;&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-begin z-matlab&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;Y&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator z-symbols z-matlab&quot;&gt; .* &lt;&#x2F;span&gt;&lt;span class=&quot;z-meta z-variable z-other z-valid z-matlab&quot;&gt;mascara&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-section z-parens z-end z-matlab&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;;
&lt;&#x2F;span&gt;&lt;span class=&quot;z-source z-matlab&quot;&gt;&lt;span class=&quot;z-keyword z-control z-matlab&quot;&gt;end&lt;&#x2F;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote class=&quot;markdown-alert-important&quot;&gt;
	&lt;p&gt;&lt;strong&gt;Error que cometí:&lt;&#x2F;strong&gt; En versiones anteriores usé &lt;code&gt;N&#x2F;2&lt;&#x2F;code&gt; directamente para indexar, lo que fallaba cuando &lt;code&gt;N&lt;&#x2F;code&gt; es impar. La solución correcta es &lt;code&gt;floor(N&#x2F;2)&lt;&#x2F;code&gt; en todos los índices, y construir la simetría conjugada explícitamente. Esto asegura que la máscara tenga exactamente &lt;code&gt;N&lt;&#x2F;code&gt; elementos sin importar la paridad de la longitud de la señal.&lt;&#x2F;p&gt;

&lt;&#x2F;blockquote&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;resultados&quot;&gt;Resultados&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;graficas-completas&quot;&gt;Gráficas Completas&lt;&#x2F;h3&gt;
&lt;p&gt;La siguiente figura muestra el pipeline completo para las cuatro señales: señal ideal → señal capturada por el sensor (BPW34→MAX9814) → señal reconstruida → espectro FFT con el SNR obtenido.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;github.com&#x2F;Richard7987&#x2F;Proyecto-Fisica-2do&#x2F;raw&#x2F;main&#x2F;Imagenes&#x2F;Sistema%20Laser-Fotosensor%20%E2%80%94%20Resultados%20Completos.png&quot; alt=&quot;Pipeline completo para las 4 señales de prueba: ideal, capturada, reconstruida y espectro FFT&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Lo más notable visualmente: la columna “Reconstruido” (verde) recupera la forma de onda con una fidelidad que hace casi indistinguible el resultado del original, a pesar del ruido visible en la columna “Capturado”.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;metricas-cuantitativas&quot;&gt;Métricas Cuantitativas&lt;&#x2F;h3&gt;
&lt;p&gt;Para no quedarme solo con la inspección visual, calculé tres métricas de error para cada señal. La señal reconstruida se escala antes de comparar (producto interno mínimo cuadrados) para separar el error de fase&#x2F;forma del error de amplitud:&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Señal&lt;&#x2F;th&gt;&lt;th&gt;Error RMS&lt;&#x2F;th&gt;&lt;th&gt;SNR (dB)&lt;&#x2F;th&gt;&lt;th&gt;Correlación&lt;&#x2F;th&gt;&lt;th&gt;Resultado&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Tono puro&lt;&#x2F;td&gt;&lt;td&gt;2.79 × 10⁻⁶&lt;&#x2F;td&gt;&lt;td&gt;&lt;strong&gt;102.1 dB&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;1.0000&lt;&#x2F;td&gt;&lt;td&gt;Excelente&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Acorde&lt;&#x2F;td&gt;&lt;td&gt;2.87 × 10⁻⁴&lt;&#x2F;td&gt;&lt;td&gt;&lt;strong&gt;62.1 dB&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;1.0000&lt;&#x2F;td&gt;&lt;td&gt;Excelente&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Barrido&lt;&#x2F;td&gt;&lt;td&gt;1.06 × 10⁻²&lt;&#x2F;td&gt;&lt;td&gt;&lt;strong&gt;30.5 dB&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;0.9996&lt;&#x2F;td&gt;&lt;td&gt;Muy bueno&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Compleja&lt;&#x2F;td&gt;&lt;td&gt;3.00 × 10⁻⁴&lt;&#x2F;td&gt;&lt;td&gt;&lt;strong&gt;63.1 dB&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;1.0000&lt;&#x2F;td&gt;&lt;td&gt;Excelente&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
	&lt;p&gt;&lt;strong&gt;Referencia:&lt;&#x2F;strong&gt; En audio, un SNR por encima de 20 dB ya es considerado aceptable para reproducción de voz. Por encima de 40 dB es transparente para el oído humano en la mayoría de condiciones. Los resultados de este sistema están entre 30.5 y 102.1 dB.&lt;&#x2F;p&gt;

&lt;&#x2F;blockquote&gt;
&lt;h3 id=&quot;analisis-svd&quot;&gt;Análisis SVD&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;github.com&#x2F;Richard7987&#x2F;Proyecto-Fisica-2do&#x2F;raw&#x2F;main&#x2F;Imagenes&#x2F;Analisis%20SVD%20%E2%80%94%20Espacios%20Vectoriales.png&quot; alt=&quot;Descomposicion SVD de la matriz de trayectoria para las 4 señales&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;El análisis de valores singulares confirma la intuición teórica sobre la complejidad de cada señal:&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Señal&lt;&#x2F;th&gt;&lt;th&gt;Varianza acumulada en 5 modos&lt;&#x2F;th&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Tono puro&lt;&#x2F;td&gt;&lt;td&gt;&lt;strong&gt;99.0%&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;casi toda la energía en 1–2 modos&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Acorde&lt;&#x2F;td&gt;&lt;td&gt;&lt;strong&gt;84.3%&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;~3 modos significativos (uno por frecuencia)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Barrido&lt;&#x2F;td&gt;&lt;td&gt;&lt;strong&gt;9.3%&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;energía muy distribuida&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Compleja&lt;&#x2F;td&gt;&lt;td&gt;&lt;strong&gt;88.6%&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;varios modos (armónicos)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;El caso del barrido es el más revelador: como la frecuencia cambia continuamente de 100 a 1000 Hz durante 3 segundos, ningún modo fijo puede capturar bien la señal. Necesita cientos de vectores singulares para representarse fielmente. Esto explica matemáticamente por qué tiene el SNR más bajo: el filtro FFT de umbral fijo no es el mejor para señales variantes en el tiempo.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;el-codigo-completo&quot;&gt;El Código Completo&lt;&#x2F;h2&gt;
&lt;p&gt;El script completo está disponible en el repositorio del proyecto:&lt;&#x2F;p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
	&lt;p&gt;&lt;strong&gt;Código fuente:&lt;&#x2F;strong&gt; &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;Richard7987&#x2F;Proyecto-Fisica-2do&#x2F;blob&#x2F;main&#x2F;Scripts&#x2F;script_prueba_demostracion.m&quot;&gt;script_prueba_demostracion.m&lt;&#x2F;a&gt; — MATLAB R2016b o superior, requiere Signal Processing Toolbox.&lt;&#x2F;p&gt;

&lt;&#x2F;blockquote&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;conclusiones&quot;&gt;Conclusiones&lt;&#x2F;h2&gt;
&lt;p&gt;Los resultados de la simulación son claros:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;El filtrado espectral FFT funciona.&lt;&#x2F;strong&gt; SNR de hasta 102.1 dB para el tono puro y correlación de 1.0000 en tres de las cuatro señales. El sistema recupera la forma de onda con fidelidad suficiente para reproducción de audio.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;La señal más difícil es el barrido (chirp).&lt;&#x2F;strong&gt; Con 30.5 dB y correlación 0.9996, sigue siendo muy buena, pero revela la limitación del filtro de umbral fijo: no es el mejor para señales cuya frecuencia varía en el tiempo. La &lt;strong&gt;STFT&lt;&#x2F;strong&gt; (Short-Time Fourier Transform) o una transformada Wavelet serían mejores herramientas para ese caso.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;El SVD confirma la teoría de espacios vectoriales.&lt;&#x2F;strong&gt; El rango efectivo de la señal (medido por los valores singulares) refleja directamente su complejidad: 1–2 modos para el tono puro, cientos para el barrido.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;El BPW34 supera al LDR.&lt;&#x2F;strong&gt; El shot noise del BPW34 es de apenas 0.8% de la señal, frente al 5% típico de un LDR. Esto se traduce directamente en SNR más alto y reconstrucción más fiel.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;La simulación valida la arquitectura antes del hardware.&lt;&#x2F;strong&gt; Ya sé que los algoritmos funcionan. Ahora puedo construir el sistema real con confianza.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;proximos-pasos&quot;&gt;Próximos Pasos&lt;&#x2F;h2&gt;
&lt;p&gt;El hardware está definido y en camino:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Montaje físico:&lt;&#x2F;strong&gt; láser D18×65mm sobre soporte Neiko, BPW34 en tubo negro, circuito en protoboard 830 puntos&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Primera captura real:&lt;&#x2F;strong&gt; comparar SNR experimental con el simulado (objetivo: &amp;gt;20 dB)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Señales de prueba:&lt;&#x2F;strong&gt; tono puro de generador, luego voz, luego música&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Futuro:&lt;&#x2F;strong&gt; STFT para mejorar la reconstrucción del chirp y señales variantes en el tiempo&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;El siguiente post documentará la construcción del hardware y la primera captura real de audio.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;p&gt;&lt;em&gt;Este proyecto es parte del curso de Física II (Ondas, Oscilaciones y Espacios Vectoriales), segundo semestre. Todo el código es de acceso libre en &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;Richard7987&#x2F;Proyecto-Fisica-2do.git&quot;&gt;GitHub&lt;&#x2F;a&gt;.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
