{"id":"97f80c93-4204-4d75-88d6-8a758202988d","shortId":"4Zq3sq","kind":"skill","title":"matlab-digital-filter-design","tagline":"Designs and validates digital filters in MATLAB. Use when cleaning up noisy signals, removing interference, filtering signals, designing FIR/IIR filters (lowpass/highpass/bandpass/bandstop/notch), or comparing filters in Filter Analyzer.","description":"# MATLAB Digital Filter Design Expert\n\nYou design, implement, and validate digital filters in MATLAB (Signal Processing Toolbox + DSP System Toolbox). You help users choose the right architecture (single-stage vs efficient alternatives), generate correct code, and verify the result with plots + numbers.\n\n## Must-follow\n- **Read INDEX.md**\n- **Always write to .m files.** Never put multi-line MATLAB code directly in `evaluate_matlab_code`. Write to a `.m` file, run with `run_matlab_file`, edit on error. This saves tokens on error recovery.\n- **Preflight before ANY MATLAB call.** Before calling ANY function listed in INDEX.md — via `evaluate_matlab_code`, `run_matlab_file`, or `.m` file — read the required cards first. State `Preflight: [cards]` at top of response. No exceptions.\n- **Do not guess key requirements.** If *Mode* (streaming vs offline) or *Phase requirement* is not stated, **ask**.  \n  You may analyze the signal first (spectrum, peaks, bandwidth), but you must not silently commit to `filtfilt()` or a linear‑phase design without the user’s intent.\n- **No Hz designs without Fs.** If `Fs` is unknown, **STOP and ask** (unless the user explicitly wants normalized frequency).\n- **Always pin the sample rate.**\n  - `designfilt(..., SampleRate=Fs)`\n  - `freqz(d, [], Fs)` / `grpdelay(d, [], Fs)` (plot in **Hz**)\n- **IIR stability:** prefer **SOS/CTF** forms (avoid high‑order `[b,a]` polynomials).\n\n### MATLAB Code/Function Call Best Practise\n- Write code to a `.m` file first, then run with `run_matlab_file`\n- If errors occur, edit the file and rerun — don't put all code inline in tool calls\n\n1. List MATLAB functions you'll call\n2. Check `knowledge/INDEX.md` for each (function-level + task-level tables)\n3. Read required cards\n4. State at response top:\n   ```\n   Preflight: cards/filter-analyzer.md, cards/designfilt.md\n   ```\n   or `Preflight: none required (no indexed functions)`\n\n## Planning workflow (phases)\n\n### Phase 1: Signal Analysis\n- Use MCP to analyze input data (spectrum, signal length, interference location, etc.)\n- Compute `trans_pct` and identify interference characteristics\n- This gives accurate estimates instead of guesses\n\n### Phase 2: Clarify Intent (before any overview or comparison)\n**After signal analysis, ask Mode + Phase if not stated:**\n- **Mode**: streaming (causal) | offline (batch)\n- **Phase**: zero-phase | linear-phase | don't-care\n\nUse `AskUserQuestion` with clear descriptions:\n- Streaming = real-time, sample-by-sample, must be causal\n- Offline = batch processing, can use `filtfilt()` for zero-phase\n- Zero-phase = no time shift, preserves transient shape (offline only)\n- Linear-phase = constant group delay, works both modes\n- Don't-care = minimize compute, phase distortion acceptable\n\n**Wait for answer before showing any approach comparison or overview.**\n\n### Phase 3: Architecture Selection (show only viable options)\n- Open `efficient-filtering.md` if `trans_pct < 2%`\n- Show **only viable candidates** given Mode + Phase constraints\n- Explicitly state excluded families with one-line reason\n- Use Filter Analyzer for visual comparison\n\n---\n\n## Design intake checklist\n\n### Checklist A: Required signal + frequency spec (cannot proceed without)\n\n- [ ] `Fs` (Hz)\n- [ ] Response type: lowpass / highpass / bandpass / bandstop / notch\n- [ ] Edge frequencies in Hz\n  - low/high: `Fpass`, `Fstop`\n  - bandpass/bandstop: `Fpass1`, `Fstop1`, `Fpass2`, `Fstop2`\n  - notch: center `F0` (+ bandwidth or Q)\n\nIf any item is missing → **ask**.\n\n### Checklist B: Required intent for architecture choice (must ask if unknown)\n\n- [ ] **Mode**: streaming (causal) | offline (batch)\n- [ ] **Phase**: zero‑phase | linear‑phase | don’t‑care\n- [ ] **Magnitude constraints** (make explicit):\n  - `Rp_dB` passband ripple (default **1 dB**)\n  - `Rs_dB` stopband attenuation (default **60 dB**)\n  - for asymmetric band specs: allow `Rs1_dB`, `Rs2_dB`\n\nIf Mode or Phase is unknown: ask **1–2** clarifying questions and stop.  \nDo **not** assume “offline” or “zero‑phase”.\n\n### Standard spec block (always include)\n\n```text\nFs = ___ Hz\nResponse = lowpass | highpass | bandpass | bandstop | notch\nEdges (Hz) = ...\nMagnitude = Rp = ___ dB, Rs = ___ dB  (or Rs1/Rs2)\nMode = streaming | offline\nPhase = zero-phase | linear-phase | don't-care\nConstraints = latency/CPU/memory/fixed-point (if any)\n```\n\n---\n\n## Architecture checkpoint\n\nCompute these and state them before finalizing an approach:\n\n- `trans_bw = Fstop - Fpass`\n- `trans_pct = 100 * trans_bw / Fs`\n- `M_max = floor(Fs/(2*Fstop))` (only meaningful for lowpass-based multirate ideas)\n\n**Decision rule**\n\n- `trans_pct > 5%` → single‑stage FIR or IIR is usually fine\n- `2% ≤ trans_pct ≤ 5%` → single‑stage is possible; mention efficient alternatives if cost/latency matters\n- `trans_pct < 2%` → **STOP and do a narrow‑transition comparison**\n  Open `knowledge/cards/efficient-filtering.md`.\n\n**Important:** for `trans_pct < 2%`, do **not** blindly show all four families.  \nSelect and present only the **viable** candidates given Mode + Phase, and explicitly mark excluded families (with a one‑line reason).\n\n---\n\n## Design + verify workflow\n\n1. **Feasibility / order sanity check**\n   - Default: let `designfilt` choose minimum order from `Rp/Rs`, then query `filtord(d)`.\n   - Optional (especially for narrow transitions): use `kaiserord` / `firpmord` to estimate FIR length for planning (not as “the truth”).\n\n2. **Design candidates**\n   - Prefer `designfilt()` with explicit `Rp/Rs` and `SampleRate=Fs`.\n   - Streaming IIR: prefer `SystemObject=true` (returns `dsp.SOSFilter`) for stable, stateful filtering.\n   - Offline zero‑phase: `filtfilt()` is allowed, but you must state:\n     - forward‑backward filtering **squares magnitude** (≈ doubles dB attenuation) and effectively doubles order.\n\n3. **Compare visually when there's a choice**\n   - **Use `filterAnalyzer()`** for comparing ≥2 designs — do not write custom freqz/grpdelay plots\n   - Open `knowledge/cards/filter-analyzer.md` first\n   - Minimum displays: magnitude + group delay (add impulse response when latency is a concern)\n\n4. **Verify with numbers (not just plots)**\n   - Worst‑case passband ripple and stopband attenuation vs spec.\n   - For `filtfilt()`, verify the **effective** response (magnitude squared).\n\n5. **Deliver the output**\n   - Specs recap\n   - Derived metrics (`trans_pct`, order/taps, MPIS if relevant)\n   - Chosen architecture + why\n   - MATLAB code\n   - Verification snippet + results\n   - Implementation form (digitalFilter vs System object, SOS/CTF export)\n\nThat’s the whole job: make the workflow predictable, and make the assumptions impossible to miss.","tags":["matlab","digital","filter","design","skills","agent-skill","agent-skills","agentic-ai","agents","claude","claude-api","claude-code"],"capabilities":["skill","source-matlab","skill-matlab-digital-filter-design","topic-agent-skill","topic-agent-skills","topic-agentic-ai","topic-agents","topic-claude","topic-claude-api","topic-claude-code","topic-claude-desktop","topic-claude-skills","topic-matlab","topic-matlab-skills"],"categories":["skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/matlab/skills/matlab-digital-filter-design","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add matlab/skills","source_repo":"https://github.com/matlab/skills","install_from":"skills.sh"}},"qualityScore":"0.482","qualityRationale":"deterministic score 0.48 from registry signals: · indexed on github topic:agent-skills · 65 github stars · SKILL.md body (6,652 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-22T06:55:54.754Z","embedding":null,"createdAt":"2026-04-18T22:14:22.166Z","updatedAt":"2026-04-22T06:55:54.754Z","lastSeenAt":"2026-04-22T06:55:54.754Z","tsv":"'1':279,321,564,589,752 '100':660 '2':286,351,462,590,668,691,707,721,787,843 '3':298,450,831 '4':302,867 '5':682,694,891 '60':571 'accept':438 'accur':345 'add':859 'allow':577,814 'altern':65,701 'alway':81,216,605 'analysi':323,361 'analyz':32,172,327,482 'answer':441 'approach':445,653 'architectur':59,451,536,643,906 'ask':169,208,362,530,539,588 'askuserquest':385 'assum':597 'assumpt':933 'asymmetr':574 'attenu':569,826,880 'avoid':238 'b':241,532 'backward':820 'band':575 'bandpass':504,613 'bandpass/bandstop':514 'bandstop':505,614 'bandwidth':178,522 'base':675 'batch':372,401,546 'best':247 'blind':724 'block':604 'bw':655,662 'call':121,123,246,278,285 'candid':466,735,789 'cannot':495 'card':142,146,301 'cards/designfilt.md':309 'cards/filter-analyzer.md':308 'care':383,433,554,638 'case':875 'causal':370,399,544 'center':520 'characterist':342 'check':287,756 'checklist':488,489,531 'checkpoint':644 'choic':537,838 'choos':56,760 'chosen':905 'clarifi':352,591 'clean':15 'clear':387 'code':68,92,97,132,250,274,909 'code/function':245 'commit':184 'compar':28,832,842 'comparison':358,446,485,714 'comput':336,435,645 'concern':866 'constant':424 'constraint':470,556,639 'correct':67 'cost/latency':703 'custom':848 'd':225,228,768 'data':329 'db':560,565,567,572,579,581,620,622,825 'decis':678 'default':563,570,757 'delay':426,858 'deliv':892 'deriv':897 'descript':388 'design':5,6,23,36,39,191,199,486,749,788,844 'designfilt':221,759,791 'digit':3,9,34,43 'digitalfilt':915 'direct':93 'display':855 'distort':437 'doubl':824,829 'dsp':50 'dsp.sosfilter':804 'edg':507,616 'edit':108,265 'effect':828,887 'effici':64,700 'efficient-filtering.md':458 'error':110,115,263 'especi':770 'estim':346,778 'etc':335 'evalu':95,130 'except':152 'exclud':473,742 'expert':37 'explicit':212,471,558,740,793 'export':920 'f0':521 'famili':474,728,743 'feasibl':753 'file':85,102,107,135,138,254,261,267 'filter':4,10,21,25,29,31,35,44,481,808,821 'filteranalyz':840 'filtfilt':186,405,812,884 'filtord':767 'final':651 'fine':690 'fir':685,779 'fir/iir':24 'firpmord':776 'first':143,175,255,853 'floor':666 'follow':78 'form':237,914 'forward':819 'four':727 'fpass':512,657 'fpass1':515 'fpass2':517 'frequenc':215,493,508 'freqz':224 'freqz/grpdelay':849 'fs':201,203,223,226,229,498,608,663,667,797 'fstop':513,656,669 'fstop1':516 'fstop2':518 'function':125,282,292,316 'function-level':291 'generat':66 'give':344 'given':467,736 'group':425,857 'grpdelay':227 'guess':155,349 'help':54 'high':239 'highpass':503,612 'hz':198,232,499,510,609,617 'idea':677 'identifi':340 'iir':233,687,799 'implement':40,913 'import':717 'imposs':934 'impuls':860 'includ':606 'index':315 'index.md':80,128 'inlin':275 'input':328 'instead':347 'intak':487 'intent':196,353,534 'interfer':20,333,341 'item':527 'job':925 'kaiserord':775 'key':156 'knowledge/cards/efficient-filtering.md':716 'knowledge/cards/filter-analyzer.md':852 'knowledge/index.md':288 'latenc':863 'latency/cpu/memory/fixed-point':640 'length':332,780 'let':758 'level':293,296 'line':90,478,747 'linear':189,378,422,550,633 'linear-phas':377,421,632 'list':126,280 'll':284 'locat':334 'low/high':511 'lowpass':502,611,674 'lowpass-bas':673 'lowpass/highpass/bandpass/bandstop/notch':26 'm':84,101,137,253,664 'magnitud':555,618,823,856,889 'make':557,926,931 'mark':741 'matlab':2,12,33,46,91,96,106,120,131,134,244,260,281,908 'matlab-digital-filter-design':1 'matter':704 'max':665 'may':171 'mcp':325 'meaning':671 'mention':699 'metric':898 'minim':434 'minimum':761,854 'miss':529,936 'mode':159,363,368,429,468,542,583,625,737 'mpis':902 'multi':89 'multi-lin':88 'multir':676 'must':77,181,397,538,817 'must-follow':76 'narrow':712,772 'never':86 'noisi':17 'none':312 'normal':214 'notch':506,519,615 'number':75,870 'object':918 'occur':264 'offlin':162,371,400,419,545,598,627,809 'one':477,746 'one-lin':476 'open':457,715,851 'option':456,769 'order':240,754,762,830 'order/taps':901 'output':894 'overview':356,448 'passband':561,876 'pct':338,461,659,681,693,706,720,900 'peak':177 'phase':164,190,319,320,350,364,373,376,379,409,412,423,436,449,469,547,549,551,585,601,628,631,634,738,811 'pin':217 'plan':317,782 'plot':74,230,850,873 'polynomi':243 'possibl':698 'practis':248 'predict':929 'prefer':235,790,800 'preflight':117,145,307,311 'present':731 'preserv':416 'proceed':496 'process':48,402 'put':87,272 'q':524 'queri':766 'question':592 'rate':220 'read':79,139,299 'real':391 'real-tim':390 'reason':479,748 'recap':896 'recoveri':116 'relev':904 'remov':19 'requir':141,157,165,300,313,491,533 'rerun':269 'respons':150,305,500,610,861,888 'result':72,912 'return':803 'right':58 'rippl':562,877 'rp':559,619 'rp/rs':764,794 'rs':566,621 'rs1':578 'rs1/rs2':624 'rs2':580 'rule':679 'run':103,105,133,257,259 'sampl':219,394,396 'sample-by-sampl':393 'sampler':222,796 'saniti':755 'save':112 'select':452,729 'shape':418 'shift':415 'show':443,453,463,725 'signal':18,22,47,174,322,331,360,492 'silent':183 'singl':61,683,695 'single-stag':60 'skill' 'skill-matlab-digital-filter-design' 'snippet':911 'sos/ctf':236,919 'source-matlab' 'spec':494,576,603,882,895 'spectrum':176,330 'squar':822,890 'stabil':234 'stabl':806 'stage':62,684,696 'standard':602 'state':144,168,303,367,472,648,807,818 'stop':206,594,708 'stopband':568,879 'stream':160,369,389,543,626,798 'system':51,917 'systemobject':801 't-care':381,431,636 'tabl':297 'task':295 'task-level':294 'text':607 'time':392,414 'token':113 'tool':277 'toolbox':49,52 'top':148,306 'topic-agent-skill' 'topic-agent-skills' 'topic-agentic-ai' 'topic-agents' 'topic-claude' 'topic-claude-api' 'topic-claude-code' 'topic-claude-desktop' 'topic-claude-skills' 'topic-matlab' 'topic-matlab-skills' 'tran':337,460,654,658,661,680,692,705,719,899 'transient':417 'transit':713,773 'true':802 'truth':786 'type':501 'unknown':205,541,587 'unless':209 'use':13,324,384,404,480,774,839 'user':55,194,211 'usual':689 'valid':8,42 'verif':910 'verifi':70,750,868,885 'via':129 'viabl':455,465,734 'visual':484,833 'vs':63,161,881,916 'wait':439 'want':213 'whole':924 'without':192,200,497 'work':427 'workflow':318,751,928 'worst':874 'write':82,98,249,847 'zero':375,408,411,548,600,630,810 'zero-phas':374,407,410,629","prices":[{"id":"429099d0-3f40-4c3f-b1f2-a85e11ae2cd2","listingId":"97f80c93-4204-4d75-88d6-8a758202988d","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"matlab","category":"skills","install_from":"skills.sh"},"createdAt":"2026-04-18T22:14:22.166Z"}],"sources":[{"listingId":"97f80c93-4204-4d75-88d6-8a758202988d","source":"github","sourceId":"matlab/skills/matlab-digital-filter-design","sourceUrl":"https://github.com/matlab/skills/tree/main/skills/matlab-digital-filter-design","isPrimary":false,"firstSeenAt":"2026-04-18T22:14:22.166Z","lastSeenAt":"2026-04-22T06:55:54.754Z"}],"details":{"listingId":"97f80c93-4204-4d75-88d6-8a758202988d","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"matlab","slug":"matlab-digital-filter-design","github":{"repo":"matlab/skills","stars":65,"topics":["agent-skill","agent-skills","agentic-ai","agents","claude","claude-api","claude-code","claude-desktop","claude-skills","matlab","matlab-skills"],"license":"other","html_url":"https://github.com/matlab/skills","pushed_at":"2026-03-20T00:56:44Z","description":"A collection of Agent Skills for MATLAB development. Skills are specialized instruction sets that extend a coding agent's capabilities for specific tasks, automatically activating when needed.","skill_md_sha":"cc4694c323501c2ac54f170fa643f7465906342f","skill_md_path":"skills/matlab-digital-filter-design/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/matlab/skills/tree/main/skills/matlab-digital-filter-design"},"layout":"multi","source":"github","category":"skills","frontmatter":{"name":"matlab-digital-filter-design","license":"MathWorks BSD-3-Clause (see LICENSE)","description":"Designs and validates digital filters in MATLAB. Use when cleaning up noisy signals, removing interference, filtering signals, designing FIR/IIR filters (lowpass/highpass/bandpass/bandstop/notch), or comparing filters in Filter Analyzer.","compatibility":"Requires MATLAB with Signal Processing Toolbox and DSP System Toolbox."},"skills_sh_url":"https://skills.sh/matlab/skills/matlab-digital-filter-design"},"updatedAt":"2026-04-22T06:55:54.754Z"}}