Effacer les filtres
Effacer les filtres

Rapid Stateflow.Transition finding

4 vues (au cours des 30 derniers jours)
Massimiliano
Massimiliano le 27 Mai 2013
Is there a rapid way to find all the 'Stateflow.Transition' from a state A, to a state B?

Réponse acceptée

Siddharth
Siddharth le 30 Mai 2013
You can do that using a simple MATLAB script using the Stateflow API. Find the Stateflow API below: http://www.mathworks.com/help/stateflow/programmatic-manipulation.html
Here is a simple example that looks for transitions between the states "upshifting" and "steady_state". To run the example, open the model sf_car and run the following code:
rt = sfroot;
transArray = rt.find('-isa','Stateflow.Transition');
len_transarray = length(transArray);
x = zeros(len_transarray,1);
y = zeros(len_transarray,1);
for i = 1: len_transarray
if ~isempty(strfind(get(get(transArray(i),'Source'),'LabelString'),'upshifting'))
x(i) = i;
end
if ~isempty(strfind(get(get(transArray(i),'Destination'),'LabelString'),'steady_state'))
y(i) = i;
end
end
output = transArray(find(x>0 & y > 0))
  1 commentaire
Massimiliano
Massimiliano le 31 Mai 2013
why don't you use the 'strcmp(s1,s2)'? is the 'isempty(strfind(s1,s2))' more rapid? moreover, it could happen that you may find the transitions from 'upshifting' to 'steady_state', but also the transitions from 'upshifting_whatever' to 'steady_state_whatever'.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Stateflow dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by