Borrar filtros
Borrar filtros

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

6 visualizaciones (últimos 30 días)
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.

Respuestas (1)

goerk
goerk el 20 de Mzo. de 2017
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 comentario
Christian Stier
Christian Stier el 21 de Mzo. de 2017
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Event Functions en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by