"The 'Label' property name is ambiguous in the 'Transition' class " error

9 views (last 30 days)
Hello, i'm trying to create a stateflow with code. i have already created 2 states and a Transition between them :
add_block('sflib/Chart', 'autoDS/Chart'); %Create Chart Block
rt = sfroot;
m = rt.find('-isa', 'Simulink.BlockDiagram', '-and', 'Name', 'autoDS'); % block diagram
ch = m.find('-isa','Stateflow.Chart', '-and', 'Name', 'Chart'); % chart
st = Stateflow.State(ch); % state
st.Label = 'CMD_28V_Avion';
st1 = Stateflow.State(ch); % state
st1.Label = 'CMD_28V_Avion2';
st2 = Stateflow.Transition(st);
st2.Source = st;
st2.Destination = st1;
The problem is when i'm trying to set the Label of the transition :
st2.Label = '[115V==1]';
i have this error :
The 'Label' property name is ambiguous in the 'Transition' class.
I don't know if there are 'rules' for how to set Transition.Label i didn't found any informations.

Answers (1)

Rajanya
Rajanya on 12 May 2025 at 10:03
I had also encountered the same error while using MATLAB R2019a.
The error was because of the partial property name matching behaviour of MATLAB, for classes deriving 'matlab.mixin.SetGet' class (https://www.mathworks.com/help/matlab/ref/matlab.mixin.setget-class.html), which was also valid for dot notations somehow (which I think got removed later on and dot notations require the exact name matches in the current versions, as described here).
The 'st2' here, which is an object of 'Transition' class, also inherits 'matlab.mixin.SetGet' class as can be verified using 'superclasses' function of MATLAB:
new_system('autoDS');
add_block('sflib/Chart', 'autoDS/Chart');
rt = sfroot;
m = rt.find('-isa', 'Simulink.BlockDiagram', '-and', 'Name', 'autoDS');
ch = m.find('-isa','Stateflow.Chart', '-and', 'Name', 'Chart');
st = Stateflow.State(ch);
%st.Label = 'CMD_28V_Avion'; This line will error out in current
%version(s), hence commented
st1 = Stateflow.State(ch);
st2 = Stateflow.Transition(st);
st2.Source = st;
st2.Destination = st1;
superclasses(st2) %Give out the classes which Transition class inherits
Superclasses for class Stateflow.Transition: Stateflow.DDObject Simulink.DABaseObject handle matlab.mixin.Heterogeneous dynamicprops matlab.mixin.SetGet matlab.mixin.internal.JavaVisible da.internal.SupportsApplicationData
The issue with using 'Label' in 'st2', but not in 'st', arose because 'st2' (Transition classes) contained two properties that began with 'Label': 'LabelString' and 'LabelPosition'. When you tried to access a property using the partial name 'Label', MATLAB found multiple matches and could not resolve the ambiguity, resulting in the error. In contrast, 'st' (State classes) only had one property starting with 'Label' - 'LabelString', so MATLAB could uniquely identify and access it without any ambiguity.
Replacing the partial property name 'Label' with 'LabelString' for 'st2' would have resolved the issue.
However, this isn't relevant now since partial property names (like 'Label' here) would not be recognized at all and an error would be thrown on trying to access them using dot notations in all cases (irrespective of the class). The 'get/set' methods of accessing properties, though, continue to work with partial names, as demonstrated below-
st2 %notice 'LabelString' and 'LabelPosition'
st2 =
Transition with properties: Id: 54 Path: 'autoDS/Chart' SSIdNumber: 3 Destination: [1x1 Stateflow.State] DestinationOClock: 6.5000 Source: [1x1 Stateflow.State] SourceOClock: 6.5000 LabelString: '?' Trigger: '' Condition: '' ConditionAction: '' TransitionAction: '' Debug: [1x1 Stateflow.TransDebug] ExecutionOrder: 1 SourceEndpoint: [30 60] DestinationEndpoint: [30 60] MidPoint: [30 54] LabelPosition: [30 60 8.6719 16] Machine: [1x1 Stateflow.Machine] Chart: [1x1 Stateflow.Chart] ArrowSize: 8 Subviewer: [1x1 Stateflow.Chart] Description: '' Document: '' RequirementInfo: '' FontSize: 12 Tag: [] IsExplicitlyCommented: 0 IsImplicitlyCommented: 0 CommentText: '' IsVariant: 0 IsCommented: 0
set(st2, 'LabelStr', '[115V==1]') % works
get(st2,'LabelStr') %however, using 'Label' here would again have caused ambiguity error
ans = '[115V==1]'
st2.LabelStr %does not work; used to work in (or before) R2019a at least
Unrecognized method, property, or field 'LabelStr' for class 'Stateflow.Transition'.
You can get more information on 'superclasses' function by executing the following command from MATLAB Command Window-
doc superclasses
Thanks!

Categories

Find more on Modeling in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!