matlab-review-fi-object-code

Reviews MATLAB fixed-point fi code for performance, code generation efficiency, and correctness.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-review-fi-object-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-review-fi-object-code
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/code-generation/matlab-review-fi-object-code
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-review-fi-object-code

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Fixed-point MATLAB code using fi objects often suffers from slow simulation, bloated generated C code, and subtle correctness bugs like unintended word-length growth. This Skill applies an 11-point checklist to detect these antipatterns and suggest idiomatic fixes.

Core Features & Use Cases

  • Performance Review: Detects scalar fi() calls in loops, missing preallocation, and slow name-value constructors, recommending vectorization and numerictype prototypes.
  • Code Generation Efficiency: Evaluates fimath settings (rounding, overflow, product/sum modes) against C, DSP, or FPGA targets, and flags division and transcendental functions that generate inefficient code.
  • Correctness & Patterns: Identifies missing subscripted assignment that causes accumulator bit growth, hardcoded types that should be separated into types tables, and misuse of quantizenumeric versus fi.
  • Use Case: Before generating C code with MATLAB Coder from a fixed-point FIR filter, run this review to catch default fimath bloat, unvectorized fi construction, and division operations that would inflate the generated code.

Quick Start

Review my MATLAB file for fixed-point fi best practices and report any performance, code generation, or correctness issues.

Frequently Asked Questions about matlab-review-fi-object-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I speed up slow fi object code in MATLAB?

Vectorize fi() calls by passing entire arrays instead of constructing objects element-by-element in loops, and preallocate output arrays with zeros(...,'like',prototype). For further acceleration, use fiaccel to compile to MEX or quantizenumeric to stay in double.

What fimath settings should I use for C code generation?

For C targets with MATLAB Coder, use Floor rounding, Wrap overflow, and KeepLSB product and sum modes with 32-bit word lengths to model integer truncation. Default fimath (Nearest, Saturate, FullPrecision) generates bloated code with sign-extension and overflow checks.

When should I use quantizenumeric instead of fi objects?

Use quantizenumeric when your algorithm stays in double and you only need to inject quantization effects at specific points, avoiding fi object overhead. Use fi when you need full fixed-point arithmetic rules, instrumentation, or code generation.

Why does my fi accumulator keep growing in word length?

The assignment acc = acc + x(n) creates a new fi object whose type grows under FullPrecision fimath. Use subscripted assignment acc(:) = acc + x(n) to preserve the accumulator's declared numerictype across iterations.

How do I replace sin or sqrt in fixed-point MATLAB code?

For C targets, use FunctionApproximation.Problem from Fixed-Point Designer to generate optimized lookup tables. For FPGA or hardware targets, use CORDIC functions like cordicsin, which map efficiently to shift-add logic without large ROM.

When should I not use this fi code review?

Skip this review for code using only built-in integer types like int8 without fi objects, pure floating-point algorithms with no fixed-point intent, or Simulink-only workflows where fixed-point is configured through block dialogs.