MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

  • HDL code generation (requires an HDL Coder™ license)

  • Executable files or shared libraries generation (requires a MATLAB Compiler license)


NoteCheck the product documentation to confirm fixed-point, code generation, and
MATLAB Compiler support for the specific System objects you want to use.


System objects use a minimum of two commands to process data:



  • Creation of the object (such as, fft256 = dsp.FFT)

  • Running data through the object (such as, fft256(x))


This separation of creation from execution lets you create multiple, persistent, reusable
objects, each with different settings. Using this approach avoids repeated input validation
and verification, allows for easy use within a programming loop, and improves overall
performance. In contrast, MATLAB functions must validate parameters every time you
call the function.


In addition to the System objects provided with System Toolboxes, you can create your
own System objects. See “Create System Objects”.


Running a System Object


To run a System object and perform the operation defined by its algorithm, you call the
object as if it were a function. For example, to create an FFT object that uses the
dsp.FFT System object, specifies a length of 1024, and names it dft, use:


dft = dsp.FFT('FFTLengthSource','Property','FFTLength',1024);


To run this object with the input x, use:


dft(x);


If you run a System object without any input arguments, you must include empty
parentheses. For example, asysobj().


When you run a System object, it also performs other important tasks related to data
processing, such as initialization and handling object states.


NoteAn alternative way to run a System object is to use the step function. For example,
for an object created using dft = dsp.FFT, you can run it using step(dft,x).


What Are System Objects?
Free download pdf