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

조회 수: 4 (최근 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 CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by