Set parameter of masked subsystem

6 次查看(过去 30 天)
Patrick
Patrick 2023-6-12
回答: Pratheek 2023-6-19
I've the following problem. I've a masked system (let's call it A) which takes a parameter (parA) which I want to use to compute a variable (var) which will be a parameter (parB) of another masked system (B), which is a subsystem of A. (So in the end I want parB = var).
I've tried to achieve this by computing 'var' in the intialization code of mask A and then setting 'var' as value of 'parB' in mask B. However, when trying to simulate, it gives the error 'Failed to evaluate mask initialization commands.' because the variable 'var' does not exist. I assume this is because it first runs the initialization of mask B, which fails as 'var' is not available as the intialization of maks A has not run yet.
I was wondering if there's a way to get around this issue.

回答(1 个)

Pratheek
Pratheek 2023-6-19
Hi Patrick,
This is because the variables are stored in different mask workspaces, so to avoid this problem save the variables(parA) of first subsystem(A) into the base workspace and then load them into the sub system(B) inside it, you can leverage the help of ''assignin" and "evalin" functions
Hope this helps you!

类别

Help CenterFile Exchange 中查找有关 Subsystems 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by