variables with scope local to subsystem

1 view (last 30 days)
Matthew Mishrikey
Matthew Mishrikey on 10 Mar 2022
I'm a bit confused about variable scope. I think I know what's going on but am looking for confirmation and maybe advice on the correct way to handle things.
Presently my subsystem uses base workspace variables. I thought that would break when I duplicate the subsystem and the base workspace values get clobbered, but it works okay.
I think what happens is that one subsystem is initialized at a time. Its initfcn callback sets the base workspace variable for itself. Then when the next subsystem is initialized, the base workspace variables are changed. After the sim, the base workspace variables are set to those of the last initialized block.
Is there a way to have duplicate variables scoped to each subsystem?

Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!