<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><title>Make a Digital Filter — makeFilter • oce</title><script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"><script src="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="../deps/font-awesome-6.4.2/css/all.min.css" rel="stylesheet"><link href="../deps/font-awesome-6.4.2/css/v4-shims.min.css" rel="stylesheet"><script src="../deps/headroom-0.11.0/headroom.min.js"></script><script src="../deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="../deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="../deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="../deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="../deps/search-1.0.0/fuse.min.js"></script><script src="../deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="../pkgdown.js"></script><meta property="og:title" content="Make a Digital Filter — makeFilter"><meta name="description" content="The filter is suitable for use by filter(),
convolve() or (for the asKernal=TRUE case) with
kernapply().  Note that convolve() should be faster
than filter(), but it cannot be used if the time series has
missing values.  For the Blackman-Harris filter, the half-power frequency is
at 1/m cycles per time unit, as shown in the &amp;#8220;Examples&amp;#8221;
section.  When using filter() or kernapply() with
these filters, use circular=TRUE."><meta property="og:description" content="The filter is suitable for use by filter(),
convolve() or (for the asKernal=TRUE case) with
kernapply().  Note that convolve() should be faster
than filter(), but it cannot be used if the time series has
missing values.  For the Blackman-Harris filter, the half-power frequency is
at 1/m cycles per time unit, as shown in the &amp;#8220;Examples&amp;#8221;
section.  When using filter() or kernapply() with
these filters, use circular=TRUE."></head><body>
    <a href="#main" class="visually-hidden-focusable">Skip to contents</a>


    <nav class="navbar navbar-expand-lg fixed-top bg-light" data-bs-theme="light" aria-label="Site navigation"><div class="container">

    <a class="navbar-brand me-2" href="../index.html">oce</a>

    <small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">1.8-4</small>


    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div id="navbar" class="collapse navbar-collapse ms-3">
      <ul class="navbar-nav me-auto"><li class="active nav-item"><a class="nav-link" href="../reference/index.html">Reference</a></li>
<li class="nav-item dropdown">
  <button class="nav-link dropdown-toggle" type="button" id="dropdown-articles" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">Articles</button>
  <ul class="dropdown-menu" aria-labelledby="dropdown-articles"><li><a class="dropdown-item" href="../articles/A_oce.html">1. Introduction to Oce</a></li>
    <li><a class="dropdown-item" href="../articles/B_ctd.html">2. Analysis of CTD data</a></li>
    <li><a class="dropdown-item" href="../articles/C_adp.html">3. Analysis of acoustic-Doppler data</a></li>
    <li><a class="dropdown-item" href="../articles/D_map_projections.html">4. Using map projections</a></li>
    <li><a class="dropdown-item" href="../articles/E_flags.html">5. Dealing with data-quality flags</a></li>
    <li><a class="dropdown-item" href="../articles/F_subclassing.html">6. Subclassing oce objects</a></li>
    <li><a class="dropdown-item" href="../articles/G_altering_defaults.html">7. Altering oce Defaults</a></li>
    <li><a class="dropdown-item" href="../articles/H_tides.html">8. Tidal Analysis</a></li>
  </ul></li>
<li class="nav-item"><a class="nav-link" href="../news/index.html">Changelog</a></li>
      </ul><ul class="navbar-nav"><li class="nav-item"><form class="form-inline" role="search">
 <input class="form-control" type="search" name="search-input" id="search-input" autocomplete="off" aria-label="Search site" placeholder="Search for" data-search-index="../search.json"></form></li>
<li class="nav-item"><a class="external-link nav-link" href="https://github.com/dankelley/oce/" aria-label="GitHub"><span class="fa fab fa-github fa-lg"></span></a></li>
      </ul></div>


  </div>
</nav><div class="container template-reference-topic">
<div class="row">
  <main id="main" class="col-md-9"><div class="page-header">

      <h1>Make a Digital Filter</h1>
      <small class="dont-index">Source: <a href="https://github.com/dankelley/oce/blob/HEAD/R/misc.R" class="external-link"><code>R/misc.R</code></a></small>
      <div class="d-none name"><code>makeFilter.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>The filter is suitable for use by <code><a href="https://rdrr.io/r/stats/filter.html" class="external-link">filter()</a></code>,
<code><a href="https://rdrr.io/r/stats/convolve.html" class="external-link">convolve()</a></code> or (for the <code>asKernal=TRUE</code> case) with
<code><a href="https://rdrr.io/r/stats/kernapply.html" class="external-link">kernapply()</a></code>.  Note that <code><a href="https://rdrr.io/r/stats/convolve.html" class="external-link">convolve()</a></code> should be faster
than <code><a href="https://rdrr.io/r/stats/filter.html" class="external-link">filter()</a></code>, but it cannot be used if the time series has
missing values.  For the Blackman-Harris filter, the half-power frequency is
at <code>1/m</code> cycles per time unit, as shown in the “Examples”
section.  When using <code><a href="https://rdrr.io/r/stats/filter.html" class="external-link">filter()</a></code> or <code><a href="https://rdrr.io/r/stats/kernapply.html" class="external-link">kernapply()</a></code> with
these filters, use <code>circular=TRUE</code>.</p>
    </div>

    <div class="section level2">
    <h2 id="ref-usage">Usage<a class="anchor" aria-label="anchor" href="#ref-usage"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">makeFilter</span><span class="op">(</span></span>
<span>  type <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"blackman-harris"</span>, <span class="st">"rectangular"</span>, <span class="st">"hamming"</span>, <span class="st">"hann"</span><span class="op">)</span>,</span>
<span>  <span class="va">m</span>,</span>
<span>  asKernel <span class="op">=</span> <span class="cn">TRUE</span></span>
<span><span class="op">)</span></span></code></pre></div>
    </div>

    <div class="section level2">
    <h2 id="arguments">Arguments<a class="anchor" aria-label="anchor" href="#arguments"></a></h2>


<dl><dt id="arg-type">type<a class="anchor" aria-label="anchor" href="#arg-type"></a></dt>
<dd><p>a string indicating the type of filter to use.  (See Harris
(1978) for a comparison of these and similar filters.)</p><ul><li><p><code>"blackman-harris"</code> yields a modified raised-cosine filter designated
as "4-Term (-92 dB) Blackman-Harris" by Harris (1978; coefficients given in
the table on page 65).  This is also called "minimum 4-sample Blackman
Harris" by that author, in his Table 1, which lists figures of merit as
follows: highest side lobe level -92dB; side lobe fall off -6 db/octave;
coherent gain 0.36; equivalent noise bandwidth 2.00 bins; 3.0-dB bandwidth
1.90 bins; scallop loss 0.83 dB; worst case process loss 3.85 dB; 6.0-db
bandwidth 2.72 bins; overlap correlation 46 percent for 75\<!-- % overlap and 3.8 -->
for 50\<!-- % overlap.  Note that the equivalent noise bandwidth is the width of -->
a spectral peak, so that a value of 2 indicates a cutoff frequency of
<code>1/m</code>, where <code>m</code> is as given below.</p></li>
<li><p><code>"rectangular"</code> for a flat filter.  (This is just for convenience.  Note that
<code><a href="https://rdrr.io/r/stats/kernel.html" class="external-link">kernel</a></code><code>("daniell",....)</code> gives the same result, in kernel form.)
<code>"hamming"</code> for a Hamming filter (a raised-cosine that does not taper
to zero at the ends)</p></li>
<li><p><code>"hann"</code> (a raised cosine that tapers to zero at the ends).</p></li>
</ul></dd>


<dt id="arg-m">m<a class="anchor" aria-label="anchor" href="#arg-m"></a></dt>
<dd><p>length of filter.  This should be an odd number, for any
non-rectangular filter.</p></dd>


<dt id="arg-askernel">asKernel<a class="anchor" aria-label="anchor" href="#arg-askernel"></a></dt>
<dd><p>boolean, set to <code>TRUE</code> to get a smoothing kernel for
the return value.</p></dd>

</dl></div>
    <div class="section level2">
    <h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
    <p>If <code>asKernel</code> is <code>FALSE</code>, this returns a list of filter
coefficients, symmetric about the midpoint and summing to 1.  These may be
used with <code><a href="https://rdrr.io/r/stats/filter.html" class="external-link">filter()</a></code>, which should be provided with argument
<code>circular=TRUE</code> to avoid phase offsets.  If <code>asKernel</code> is
<code>TRUE</code>, the return value is a smoothing kernel, which can be applied to
a timeseries with <code><a href="https://rdrr.io/r/stats/kernapply.html" class="external-link">kernapply()</a></code>, whose bandwidth can be determined
with <code><a href="https://rdrr.io/r/stats/kernel.html" class="external-link">bandwidth.kernel()</a></code>, and which has both print and plot
methods.</p>
    </div>
    <div class="section level2">
    <h2 id="sample-of-usage">Sample of Usage<a class="anchor" aria-label="anchor" href="#sample-of-usage"></a></h2>


<div class="sourceCode"><pre><code><span></span>
<span><span class="co"># need signal package for this example</span></span>
<span><span class="va">r</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">rnorm</a></span><span class="op">(</span><span class="fl">2048</span><span class="op">)</span></span>
<span><span class="va">rh</span> <span class="op">&lt;-</span> <span class="fu">stats</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/stats/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="va">r</span>, <span class="va">H</span><span class="op">)</span></span>
<span><span class="va">rh</span> <span class="op">&lt;-</span> <span class="va">rh</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/is.finite.html" class="external-link">is.finite</a></span><span class="op">(</span><span class="va">rh</span><span class="op">)</span><span class="op">]</span> <span class="co"># kludge to remove NA at start/end</span></span>
<span><span class="va">sR</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/spectrum.html" class="external-link">spectrum</a></span><span class="op">(</span><span class="va">r</span>, plot<span class="op">=</span><span class="cn">FALSE</span>, spans<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">11</span>, <span class="fl">5</span>, <span class="fl">3</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="va">sRH</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/spectrum.html" class="external-link">spectrum</a></span><span class="op">(</span><span class="va">rh</span>, plot<span class="op">=</span><span class="cn">FALSE</span>, spans<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">11</span>, <span class="fl">5</span>, <span class="fl">3</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/par.html" class="external-link">par</a></span><span class="op">(</span>mfrow<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">2</span>, <span class="fl">1</span><span class="op">)</span>, mar<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">3</span>, <span class="fl">3</span>, <span class="fl">1</span>, <span class="fl">1</span><span class="op">)</span>, mgp<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">2</span>, <span class="fl">0.7</span>, <span class="fl">0</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/plot.default.html" class="external-link">plot</a></span><span class="op">(</span><span class="va">sR</span><span class="op">$</span><span class="va">freq</span>, <span class="va">sRH</span><span class="op">$</span><span class="va">spec</span><span class="op">/</span><span class="va">sR</span><span class="op">$</span><span class="va">spec</span>, xlab<span class="op">=</span><span class="st">"Frequency"</span>, ylab<span class="op">=</span><span class="st">"Power Transfer"</span>,</span>
<span>     type<span class="op">=</span><span class="st">"l"</span>, lwd<span class="op">=</span><span class="fl">5</span>, col<span class="op">=</span><span class="st">"gray"</span><span class="op">)</span></span>
<span><span class="va">theory</span> <span class="op">&lt;-</span> <span class="fu">freqz</span><span class="op">(</span><span class="va">H</span>, n<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/seq.html" class="external-link">seq</a></span><span class="op">(</span><span class="fl">0</span>,<span class="va">pi</span>,length.out<span class="op">=</span><span class="fl">100</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co"># Note we must square the modulus for the power spectrum</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/lines.html" class="external-link">lines</a></span><span class="op">(</span><span class="va">theory</span><span class="op">$</span><span class="va">f</span><span class="op">/</span><span class="va">pi</span><span class="op">/</span><span class="fl">2</span>, <span class="fu"><a href="https://rdrr.io/r/base/complex.html" class="external-link">Mod</a></span><span class="op">(</span><span class="va">theory</span><span class="op">$</span><span class="va">h</span><span class="op">)</span><span class="op">^</span><span class="fl">2</span>, lwd<span class="op">=</span><span class="fl">1</span>, col<span class="op">=</span><span class="st">"red"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/grid.html" class="external-link">grid</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="st">"topright"</span>, col<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"gray"</span>, <span class="st">"red"</span><span class="op">)</span>, lwd<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">5</span>, <span class="fl">1</span><span class="op">)</span>, cex<span class="op">=</span><span class="fl">2</span><span class="op">/</span><span class="fl">3</span>,</span>
<span>       legend<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"Practical"</span>, <span class="st">"Theory"</span><span class="op">)</span>, bg<span class="op">=</span><span class="st">"white"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/plot.default.html" class="external-link">plot</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/Log.html" class="external-link">log10</a></span><span class="op">(</span><span class="va">sR</span><span class="op">$</span><span class="va">freq</span><span class="op">)</span>, <span class="fu"><a href="https://rdrr.io/r/base/Log.html" class="external-link">log10</a></span><span class="op">(</span><span class="va">sRH</span><span class="op">$</span><span class="va">spec</span><span class="op">/</span><span class="va">sR</span><span class="op">$</span><span class="va">spec</span><span class="op">)</span>,</span>
<span>     xlab<span class="op">=</span><span class="st">"log10 Frequency"</span>, ylab<span class="op">=</span><span class="st">"log10 Power Transfer"</span>,</span>
<span>     type<span class="op">=</span><span class="st">"l"</span>, lwd<span class="op">=</span><span class="fl">5</span>, col<span class="op">=</span><span class="st">"gray"</span><span class="op">)</span></span>
<span><span class="va">theory</span> <span class="op">&lt;-</span> <span class="fu">freqz</span><span class="op">(</span><span class="va">H</span>, n<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/seq.html" class="external-link">seq</a></span><span class="op">(</span><span class="fl">0</span>,<span class="va">pi</span>,length.out<span class="op">=</span><span class="fl">100</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co"># Note we must square the modulus for the power spectrum</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/lines.html" class="external-link">lines</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/Log.html" class="external-link">log10</a></span><span class="op">(</span><span class="va">theory</span><span class="op">$</span><span class="va">f</span><span class="op">/</span><span class="va">pi</span><span class="op">/</span><span class="fl">2</span><span class="op">)</span>, <span class="fu"><a href="https://rdrr.io/r/base/Log.html" class="external-link">log10</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/complex.html" class="external-link">Mod</a></span><span class="op">(</span><span class="va">theory</span><span class="op">$</span><span class="va">h</span><span class="op">)</span><span class="op">^</span><span class="fl">2</span><span class="op">)</span>, lwd<span class="op">=</span><span class="fl">1</span>, col<span class="op">=</span><span class="st">"red"</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/grid.html" class="external-link">grid</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="st">"topright"</span>, col<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"gray"</span>, <span class="st">"red"</span><span class="op">)</span>, lwd<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">5</span>, <span class="fl">1</span><span class="op">)</span>, cex<span class="op">=</span><span class="fl">2</span><span class="op">/</span><span class="fl">3</span>,</span>
<span>       legend<span class="op">=</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"Practical"</span>, <span class="st">"Theory"</span><span class="op">)</span>, bg<span class="op">=</span><span class="st">"white"</span><span class="op">)</span></span></code></pre></div>

    </div>
    <div class="section level2">
    <h2 id="references">References<a class="anchor" aria-label="anchor" href="#references"></a></h2>
    <p>F. J. Harris, 1978.  On the use of windows for harmonic analysis
with the discrete Fourier Transform.  <em>Proceedings of the IEEE</em>, 66(1),
51-83 (<code>http://web.mit.edu/xiphmont/Public/windows.pdf</code>.)</p>
    </div>
    <div class="section level2">
    <h2 id="author">Author<a class="anchor" aria-label="anchor" href="#author"></a></h2>
    <p>Dan Kelley</p>
    </div>

    <div class="section level2">
    <h2 id="ref-examples">Examples<a class="anchor" aria-label="anchor" href="#ref-examples"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span class="r-in"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://dankelley.github.io/oce/">oce</a></span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># 1. Demonstrate step-function response</span></span></span>
<span class="r-in"><span><span class="va">y</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/rep.html" class="external-link">rep</a></span><span class="op">(</span><span class="fl">1</span>, <span class="fl">10</span><span class="op">)</span>, <span class="fu"><a href="https://rdrr.io/r/base/rep.html" class="external-link">rep</a></span><span class="op">(</span><span class="op">-</span><span class="fl">1</span>, <span class="fl">10</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">x</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/seq.html" class="external-link">seq_along</a></span><span class="op">(</span><span class="va">y</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/graphics/plot.default.html" class="external-link">plot</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">y</span>, type <span class="op">=</span> <span class="st">"o"</span>, ylim <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="op">-</span><span class="fl">1.05</span>, <span class="fl">1.05</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">BH</span> <span class="op">&lt;-</span> <span class="fu">makeFilter</span><span class="op">(</span><span class="st">"blackman-harris"</span>, <span class="fl">11</span>, asKernel <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">H</span> <span class="op">&lt;-</span> <span class="fu">makeFilter</span><span class="op">(</span><span class="st">"hamming"</span>, <span class="fl">11</span>, asKernel <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">yBH</span> <span class="op">&lt;-</span> <span class="fu">stats</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/stats/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="va">y</span>, <span class="va">BH</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/graphics/points.html" class="external-link">points</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">yBH</span>, col <span class="op">=</span> <span class="fl">2</span>, type <span class="op">=</span> <span class="st">"o"</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">yH</span> <span class="op">&lt;-</span> <span class="fu">stats</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/stats/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="va">y</span>, <span class="va">H</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/graphics/points.html" class="external-link">points</a></span><span class="op">(</span><span class="va">yH</span>, col <span class="op">=</span> <span class="fl">3</span>, type <span class="op">=</span> <span class="st">"o"</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/graphics/legend.html" class="external-link">legend</a></span><span class="op">(</span><span class="st">"topright"</span>,</span></span>
<span class="r-in"><span>    col <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">3</span>, cex <span class="op">=</span> <span class="fl">2</span> <span class="op">/</span> <span class="fl">3</span>, pch <span class="op">=</span> <span class="fl">1</span>,</span></span>
<span class="r-in"><span>    legend <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"input"</span>, <span class="st">"Blackman Harris"</span>, <span class="st">"Hamming"</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="makeFilter-1.png" alt="" width="700" height="700"></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># 2. Show theoretical and practical filter gain, where</span></span></span>
<span class="r-in"><span><span class="co">#    the latter is based on random white noise, and</span></span></span>
<span class="r-in"><span><span class="co">#    includes a particular value for the spans</span></span></span>
<span class="r-in"><span><span class="co">#    argument of spectrum(), etc.</span></span></span>
<span class="r-in"><span></span></span>
</code></pre></div>
    </div>
  </main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
    </nav></aside></div>


    <footer><div class="pkgdown-footer-left">
  <p>Developed by Dan Kelley, Clark Richards.</p>
</div>

<div class="pkgdown-footer-right">
  <p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.1.0.9000.</p>
</div>

    </footer></div>





  </body></html>

