RunMat
GitHub

fir1 — Design windowed-sinc FIR filters.

fir1(n, Wn) designs an order-n FIR filter using a Hamming-windowed sinc response. Scalar Wn creates a low-pass filter by default; a two-element Wn creates a band-pass filter by default. Add a filter type string for high-pass or stop-band designs.

Syntax

fir1(n, Wn)

How fir1 works

  • Returns a row vector with n + 1 coefficients.
  • Wn uses MATLAB's normalized digital convention where 1 is Nyquist.
  • Supported filter types are low, high, bandpass, and stop.
  • A custom window vector of length n + 1 may be supplied.
  • Filters are scaled by default; pass noscale to skip passband normalization.

Does RunMat run fir1 on the GPU?

Host-side coefficient design only.

The resulting coefficient vector can be passed to filter or filtfilt with gpuArray signal data.

Examples

Design a low-pass FIR filter

b = fir1(4, 0.5);
fprintf('%d %.4f\n', length(b), sum(b));

Expected output:

5 1.0000

Design coefficients for a FIR low-pass response plot

fs = 1000;
fc = 100;
N = 51;
wn = fc / (fs/2);
b = fir1(N-1, wn, 'low');
[H, w] = freqz(b, 1, 512, fs);
fprintf('%d %.1f %.1f\n', length(b), w(1), w(end));

Expected output:

51 0.0 499.0

Use a custom rectangular window without scaling

w = ones(1, 11);
b = fir1(10, 0.3, w, 'noscale');

Using fir1 with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how fir1 changes the result.

Run a small fir1 example, explain the result, then change one input and compare the output.

FAQ

What window does fir1 use by default?

RunMat uses a symmetric Hamming window, matching MATLAB's default FIR design workflow.

Can the coefficients be used with filtfilt?

Yes. Use filtfilt(b, 1, x) for zero-phase FIR filtering.

Does fir1 run on the GPU?

No. It generates a small coefficient vector on the host. GPU acceleration applies when those coefficients are used by filtering builtins with gpuArray signals.

Elementwise

abs · angle · complex · conj · double · exp · expm1 · factorial · gamma · heaviside · hypot · imag · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · sign · single · sqrt · times

Trigonometry

acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · deg2rad · rad2deg · sin · sind · sinh · tan · tand · tanh

Reduction

all · any · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · mean · median · min · nnz · prod · std · sum · trapz · var

Rounding

ceil · fix · floor · mod · rem · round

Factor

chol · eig · lu · qr · svd

Solve

cond · det · inv · linsolve · norm · null · pinv · rank · rcond · rref

Fft

fft · fft2 · fftshift · ifft · ifft2 · ifftshift

Interpolation

interp1 · interp2 · pchip · ppval · spline

Symbolic

limit · sym · syms

Ode

ode15s · ode23 · ode45

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how fir1 is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.