How to make static variable in Simulink

조회 수: 23 (최근 30일)
Benjamin
Benjamin 2011년 2월 28일
I have several identical simulink models, where only the parameters vary:
Simulink block 1 uses the variables x.a{1}, x.b{1}, x.c{1} etc.
Simulink block 2 uses the variables x.1{2}, x.b{2}, x.c{2} etc
... up to Simulink block n using x.a{n} etc. The constants are used in gains, sums state space models etc.
How can i avoid hard coding the above numbers 1 through n in each and every block? I.e. i want Simulink block 1 to only contain the number 1 one time.
Hope this makes sense :)
Benjamin

채택된 답변

Sebastian
Sebastian 2011년 2월 28일
You could use a masked subsystem and just have the block instance number n as a parameter. Then in the mask initialization function you can access the structure fields and map to some local variables.
  댓글 수: 3
Paulo Silva
Paulo Silva 2011년 2월 28일
Unless a variable is defined in a mask that variable will be the same one that's on your workspace, when your start the simulation simulink gets the values for each variable (for example one Constant block with the variable MyVar in the Value).
Benjamin
Benjamin 2011년 3월 12일
Ok thanks that makes sense :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by