Set Property for Component
이전 댓글 표시
I have a model with several nested levels (i.e. - spacecraft > payload > payload component). I am having trouble updating the property of such a payload component via the command line. The component has been made a Simulink model as I want to be able to re-use it in other architectures and models and produce the same behavior. The component also has a component stereotype applied with 3 properties: mass, power and volume. I am trying to update the mass value of the particular instantiation of the payload component in my current model using the "setProperty" command. Here's some of my code:
% Load the model and create object for System Composer architecture model
model = systemcomposer.loadModel(<payload component Simulink model>);
arch = get(model,'Architecture');
% Create object for the component that needs to be updated
comp = get(arch,'Components');
% Update component property
setProperty(comp,'<profile>.<stereotype>.mass','7','kg')
However, I get the following error:
No method 'setProperty' with matching signature found for class 'systemcomposer.arch.Element'.
Error in systemcomposer.arch.Component/setProperty
Strangely, "comp" is empty - a 0x0 Component. If instead I export the model using:
systemcomposer.exportModel(<payload component Simulink model>)
I get a 1x1 struct where the first element is a 1x8 table of "components", one of which is the mass property I am trying to update. What am I missing?
댓글 수: 1
Aimee Khan
2021년 6월 18일
편집: Aimee Khan
2021년 6월 18일
The error message is not helpful to diagnose the problem. It would be easier if we could see your code without the chevrons <> replacing your inputs. What version of MATLAB are you using?
채택된 답변
추가 답변 (1개)
Aimee Khan
2021년 6월 18일
편집: Aimee Khan
2021년 6월 18일
To set property for a component means that a stereotype with properties is applied on the component. In order to have a stereotype and profile to define, go into the Profile Editor and create a stereotype with properties to apply to components. For more information, see Define Profiles and Stereotypes and then, Use Stereotypes and Profiles. For a code example, see the example for setProperty. To find a component in the model to set a property for, see lookup.
Here is an example with an existing model:
Launch the keyless entry system project.
scKeylessEntrySystem
Load the model and find the FOB Locator System component.
model = systemcomposer.loadModel('KeylessEntryArchitecture');
comp = lookup(model,'Path','KeylessEntryArchitecture/FOB Locator System');
Set the Cost property on the component.
setProperty(comp,'AutoProfile.System.Cost','200','USD')
카테고리
도움말 센터 및 File Exchange에서 Author Architecture Models에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!