Documentation

What Are System Objects?

A System object™ is a specialized MATLAB®目的。系统工具箱包括系统对象,大多数系统工具箱也具有MATLAB功能和Simulink万博1manbetx®blocks. System objects are designed specifically for implementing and simulating dynamic systems with inputs that change over time. Many signal processing, communications, and controls systems are dynamic. In a dynamic system, the values of the output signals depend on both the instantaneous values of the input signals and on the past behavior of the system. System objects use internal states to store that past behavior, which is used in the next computational step. As a result, System objects are optimized for iterative computations that process large streams of data in segments, such as video and audio processing systems. This ability to process streaming data provides the advantage of not having to hold large amounts of data in memory. Use of streaming data also allows you to use simplified programs that use loops efficiently.

例如,您可以在系统中使用系统对象,该系统从文件中读取数据,过滤数据,然后将过滤的输出写入另一个文件。通常,在每个循环迭代中将指定量的数据传递给过滤器。文件读取器对象使用状态来跟踪文件中开始读取下一个数据的位置。同样,文件写入对象跟踪上次将数据写入输出文件的位置,以免数据覆盖。过滤对象保持自己的内部状态,以确保正确执行过滤。该图代表系统的单个循环。

这些优势使系统对象非常适合处理流数据。

许多系统对象支持:万博1manbetx

  • Fixed-point arithmetic (requires a Fixed-Point Designer™ license)

  • C代码生成(需要一个MATLAB Coder™或者Simulink Coderlicense)

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

  • 可执行文件或共享库生成(需要一个MATLAB编译器™license)

不te

Check the product documentation to confirm fixed-point, code generation, andMATLAB Compiler万博1manbetx支持您要使用的特定系统对象。

系统对象使用至少两个命令来处理数据:

  • Creation of the object (such as,FFT256 = DSP.FFT)

  • 通过对象运行数据(例如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创建系统对象

Running a System Object

要运行系统对象并执行由其算法定义的操作,请将对象称为函数。例如,创建一个使用fft对象dsp.fft系统对象指定1024的长度,并将其命名dft使用:

dft = dsp.fft('FFTLengthSource','Property',“ fftlength”,1024);
To run this object with the inputx使用:
dft(x);
如果您在没有任何输入参数的情况下运行系统对象,则必须包括空括号。例如,asysobj()

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

不te

An alternative way to run a System object is to use thestepfunction. For example, for an object created usingdft = dsp.FFT, you can run it using步骤(DFT,X)

系统对象功能

创建系统对象后,您使用各种对象函数来处理数据或从对象或周围获取信息。用于使用函数的语法是<对象函数名称>(<系统对象名称>),加上可能的额外输入参数。例如,对于txfourier = dsp.FFT, wheretxfourieris a name you assign, you call the重置function using重置(txfourier)

Common Object Functions

All System objects support the following object functions. In cases where a function is not applicable to a particular object, calling that function has no effect on the object.

功能 描述
Run the object function, or
step

Runs the object to process data using the algorithm defined by that object.

Example: For the objectdft = dsp.fft;,通过:

  • y = dft(x)

  • y = step(dft,x)

As part of this processing, the object initializes resources, returns outputs, and updates the object states as necessary. During execution, you can change only tunable properties. Both ways of running a System object return regular MATLAB variables.

release

释放资源并允许更改系统对象属性值和使用系统对象时受到限制的其他特征。

重置 将系统对象重置为该对象的初始值。
nargin 返回系统对象算法定义接受的输入数。如果输入的数量可以更改(算法定义包括varargin), 这nargin输出为负。
Nargout Returns the number of outputs accepted by the System object algorithm definition. If the number of outputs can change (algorithm definition includesvarargout), 这Nargout输出为负。
getDiscreteState Returns a structure of the object discrete states. If the object has no discrete states,getDiscreteStatereturns an empty structure.
clone Creates another object of the same type with the same property values
isLocked Returns a logical value indicating whether the object has been called and you have not yet calledrelease在对象上。
isDone Applies only to source objects that inherit frommatlab.system.mixin.finitesource。返回逻辑值,指示是否已达到数据文件的末尾。如果特定对象没有DATA功能,则此函数值始终返回false
info Returns a structure containing characteristic information about the object. The fields of this structure vary depending on the object. If a particular object does not have characteristic information, the structure is empty.

See Also

相关话题

这个话题有帮助吗?