How can I programmatically add a Stateflow.Data ?

조회 수: 7 (최근 30일)
Houellebecq Vincent
Houellebecq Vincent 2024년 10월 18일
댓글: Houellebecq Vincent 2024년 10월 21일
I used a Mathworks tutorial (in the link under) to copy a stateflow, but data (in the sybols Pane) aren't flollowing.
How I can Copy or add Stateflow.Data ?
Thanks

답변 (1개)

Shubham
Shubham 2024년 10월 18일
편집: Shubham 2024년 10월 18일
As far as I understand, copying graphical objects also copies the Stateflow.Data objects contained by graphical objects. When you copy multiple graphical objects, the value of their Subviewer property must be the same. Also note that the array must contain only graphical objects or only nongraphical objects.
If the above conditions are satisfied, the Stateflow.Data should get copied.
For more information please check the documentation of objArray (the objects to copy) using the copy function: https://www.mathworks.com/help/stateflow/api/stateflow.clipboard.copy.html#mw_af87b90f-8fbe-430e-a5f0-03b56fe3978e
If you have further queries, please share the example you are using in order to reproduce the issue.
Happy coding!
  댓글 수: 3
Shubham
Shubham 2024년 10월 21일
Happy to know that the issue has been resolved!
Houellebecq Vincent
Houellebecq Vincent 2024년 10월 21일
sorry wrong handling I made a mistake
So I have 2 files .slx with chart:
file_1.slx :
file_2.slx :
My code :
open_system('File_1.slx')
open_system('File_2.slx')
ch = find(sfroot,'-isa','Stateflow.Chart');
sA = find(ch,'-isa','Stateflow.State','Name','Etat2Copie');
sB = find(ch,'-isa','Stateflow.State','Name','Etat_parent');
sB.IsSubchart = true;
% sB.IsGrouped = true;
objArrayS = find(sA,'-isa','Stateflow.State');
objArrayS = setdiff(objArrayS,sA);
objArrayT = find(sA,'-isa','Stateflow.Transition');
objArray = [objArrayS; objArrayT];
cb = sfclipboard;
copy(cb,objArray);
pasteTo(cb,sB);
sB.IsSubchart = false;
sB.IsGrouped = false;
Résults:
The problème is :
Symbols = find(sfroot,'-isa','Stateflow.Data')
Symbols =
0×1 empty handle
I expected the following result :
ans =
Path: 'ModeleTest/Chart1'
Id: 30
Machine: [1×1 Stateflow.Machine]
SSIdNumber: 15
Name: 'x'
Description: ''
SaveToWorkspace: 0
DataType: 'Inherit: Same as Simulink'
Props: [1×1 Stateflow.DataProps]
ParsedInfo: [1×1 Stateflow.DataParsedInfo]
CompiledSize: ''
CompiledType: 'unknown'
Tag: []
Document: ''
Port: 1
Scope: 'Output'
TestPoint: 0
OutputState: []
Debug: [1×1 Stateflow.DataDebug]
InitializeMethod: 'Expression'
UpdateMethod: 'Discrete'
LoggingInfo: [1×1 Stateflow.SigLoggingInfo]
Tunable: 1

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Model Compatibility에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by