필터 지우기
필터 지우기

Change component size in system composer

조회 수: 11 (최근 30일)
Aidin Esmkhani
Aidin Esmkhani 2023년 3월 5일
댓글: Luca Ferro 2023년 3월 9일
How can I change a component size in MATLAB system composer by means of APIs (command line or MATLAB code) ?

채택된 답변

Josh Kahn
Josh Kahn 2023년 3월 6일
Hi Aidin,
You can use System Composer native APIs for this to interact with your architecture model in an object-oriented manner:
architectureModel = systemcomposer.loadModel('MyArchitecture');
myComponent = lookup(architectureModel, Path='MyArchitecture/MyComponent')
myComponent.Position = [100 100 100 100]
For more information on components, you can reference the following doc page:
Regards,
Josh
  댓글 수: 3
Josh Kahn
Josh Kahn 2023년 3월 7일
Hi Luca,
That's a great question! There are multiple advantages to using the native APIs:
  1. Object-Oriented interaction with your architecture model
  2. The ability to take advantage of architecture modeling features not available in Simulink such as Stereotypes, Interfaces, Parameters, Views, Allocations, and Sequence Diagrams
  3. The APIs are designed for System Composer so you won't run into nuisance errors trying to do something using the Simulink APIs that isn't supported in System Composer
You can find the full list of System Composer APIs on this documentation page:
Hope this helps,
Josh
Luca Ferro
Luca Ferro 2023년 3월 9일
thank you for your reply. I'll nosedive into the docs you just shared. I see a lot of potential in this library, the second point sold it to me.

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

추가 답변 (1개)

Luca Ferro
Luca Ferro 2023년 3월 6일
편집: Luca Ferro 2023년 3월 6일
via script:
scTmpArc=open_system('scTmpArc') %sxTmpArc is the name of your system composer file
set_param('scTmpArc/.../..',position',[100 400 500 500]) %the first paramter is the fullpath to your block
The numbers are the dimensions in pixel [x0 y0 x1 y1] meaning that x1-x0 is the lenght, y1-y0 is the height
if you don't know the fullpath you can search for it by doing:
cmpNames=getfullname(Simulink.findBlocks('scTmpArc')) %this will list every component path in cell arrays
you can then parse the cell array to find the name you need (also via script or by hand)
Note: keep in mind that system composer is just a simulink interface from a scripting point of view. Basically all the simulink commands work for both.

카테고리

Help CenterFile Exchange에서 System Composer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by