Main Content

什么是系统对象?

System Object™是专用MATLAB®object. Many toolboxes include System objects. 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.

For example, you could use System objects in a system that reads data from a file, filters that data and then writes the filtered output to another file. Typically, a specified amount of data is passed to the filter in each loop iteration. The file reader object uses a state to track where in the file to begin the next data read. Likewise, the file writer object tracks where it last wrote data to the output file so that data is not overwritten. The filter object maintains its own internal states to ensure that the filtering is performed correctly. This diagram represents a single loop of the system.

These advantages make System objects well suited for processing streaming data.

Many System objects support:

  • 定点算术(需要定点Designer™许可证)

  • C代码生成(需要一个MATLAB CODER™or万博1manbetx®Coder执照)

  • HDL代码生成(需要HDL Coder™许可证)

  • Executable files or shared libraries generation (requires aMATLAB编译器™执照)

笔记

检查产品文档以确认定点,代码生成和MATLAB编译器support for the specific System objects you want to use.

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

  • 创建对象(例如,fft256 = dsp.FFT

  • 通过对象运行数据(例如fft256(x)

创建与执行的分离使您可以创建多个具有不同设置的多个,持久,可重复使用的对象。使用这种方法避免重复输入验证和验证,可以轻松在编程循环中使用,并改善整体性能。相比之下,MATLAB函数每次调用该函数时都必须验证参数。

除了提供系统工具箱的系统对象外,您还可以创建自己的系统对象。看Create System Objects

运行系统对象

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 thedsp.FFTSystem object, specifies a length of 1024, and names itDFT, 利用:

dft = dsp.fft(“ fftlengthsource',,,,'财产',,,,“ fftlength”,1024);
用输入运行此对象X, 利用:
DFT(x);
If you run a System object without any input arguments, you must include empty parentheses. For example,asysobj()

运行系统对象时,它还执行与数据处理有关的其他重要任务,例如初始化和处理对象状态。

笔记

运行系统对象的另一种方法是使用功能。例如,用于创建的对象dft = dsp.fft,您可以使用步(dft,x)

System Object Functions

After you create a System object, you use various object functions to process data or obtain information from or about the object. The syntax for using functions is(),加上可能的额外输入参数。例如,对于txfourier = dsp.fft, 在哪里txfourier是您分配的名称,您致电重置函数使用重置(txfourier)

常见对象功能

所有系统对象都支持以下对象功能。万博1manbetx如果函数不适用于特定对象,则调用该函数对对象没有影响。

Function 描述
运行对象函数或

运行对象使用该对象定义的算法处理数据。

例子:对于对象dft = dsp.fft;,,,,run the object via:

  • y = dft(x)

  • y = step(dft,x)

作为此处理的一部分,对象将资源初始化,返回输出并根据需要更新对象状态。在执行过程中,您只能更改可调属性。运行系统对象的两种方式都返回常规MATLAB变量。

发布

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

重置 Resets the System object to the initial values for that object.
纳尔金 返回系统对象算法定义接受的输入数。如果算法定义包括varargin, 这纳尔金output is negative.
nargout 返回输出的数量被系统接受em object algorithm definition. If the algorithm definition includesvarargout, 这nargoutoutput is negative.
克隆 创建具有相同属性值的同一类型的另一个对象
被锁住了 返回逻辑值,指示该对象是否已被调用,并且您尚未调用发布在对象上。
已经完成了 仅适用于继承的源对象matlab.system.mixin.finitesource。返回逻辑值,指示是否已达到数据文件的末尾。如果特定对象没有DATA功能,则此函数值始终返回错误的

也可以看看

Related Topics