How to implement Matlab System Object with different input rates and output rates?

5 ビュー (過去 30 日間)
AC_man
AC_man 2021 年 12 月 29 日
編集済み: Chetan 2023 年 11 月 8 日
I was trying to create a System Object that I would run as a component in Simulink.
I wanted to have a different input rate and output rate. For example the input would be at 100kHz and output would be at 20kHz. I am not sure how to implement this using stepImpl. Is there a way to do this implementation?
Also as a follow up, is there a way to do variable output rate? For example the output would change between 50kHz and 20kHz based on some internal logic of the system object?

回答 (1 件)

Chetan
Chetan 2023 年 11 月 8 日
編集済み: Chetan 2023 年 11 月 8 日
Hello @AC_man,
I understand that you are encountering challenges with implementing a MATLAB system object with differing input and output rates.
One approach to manage this situation is to use Simulink's "Rate Transition" block. Rather than handling different rates within the "stepImpl" method of the System object, you would manage this directly in the Simulink model.
Here's a simplified example:
classdef MySystem < matlab.System
% ...
methods (Access = protected)
function y = stepImpl(obj, u)
% Process the input 'u' and generate the output 'y'
% ...
end
end
% ...
end
In the Simulink model, the structure would look like this:
[Input] --> [MySystem] --> [Rate Transition] --> [Output]
You can set the Rate Transition block's output rate to 20kHz.
For more information on the Rate Transition block, Refer to the following MathWorks Documentation
Hope it helps!

カテゴリ

Help Center および File ExchangeCreate System Objects についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by