フィルターのクリア

How can I programmatically register Data Stores for the Matlab Function block, i.e. without using the Ports and Data manager?

6 ビュー (過去 30 日間)
I want to script a Matlab Function (Matlab Function Block in Simulink) for routing model values to global variables, which are linked to memory spaces on a realtime platform after code generation. The routing is defined in an external table, the routing within the model should be generated automatically via script.
The routing with the Matlab Function block works fine, the only step, which I couldn't do programmatically, is registering the global variable / the Data Store to the Matlab Function block. Manually this is done via the Ports and Data Manager.

回答 (1 件)

goerk
goerk 2017 年 3 月 20 日
I had a similar problem and the following solution worked for me (Matalb 2016b). Example Matlab function with the Name 'MyMatlabFcn':
function MyMatalbFcn(u)
global ADwinDATA_1
ADwinDATA_1 = u;
end
Code to add the global data to the Function:
% Code to programmaticaly add a Stateflow.Data Object
s = slroot;
c = s.find('-isa','Stateflow.EMChart','-and','Name','MyMatlabFcn');
data_new = Stateflow.Data(c);
data_new.Name = 'ADwinDATA_1';
data_new.Scope = 'Data Store Memory';
  1 件のコメント
Christian Stier
Christian Stier 2017 年 3 月 21 日
Many thanks, that works for me, too.
However I am wondering, if there is any solution, that works without the Stateflow toolbox, as the MatlabFcn block is a standard simulink block.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEvent Functions についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by