Search code examples
matlabsimulinkhandlestateflow

How to retrieve Handle of a State block ? Matlab


I'm actually trying to build a Stateflow with Matlab code

I would like to know if it's possible to retrieve the Handle of a State block. I tried to use get_param() :

state_handle = get_param('System/Chart/State_ON', 'Handle');

But it returns me :

No block called 'State_ON' could be found.

Is there another solution to get Handle using the name of the state?

Edit : i found and post a solution


Solution

  • Ok after many research there are 2 solutions :

    For version R2017b and after

    StateHandle = StateFinder(Chart Handle)

    For versions before R2017b

    state_handle = ch.find('-isa','Stateflow.State','-and','Name', 'State_ON');