Struct as mask input
Show older comments
Hello, I would like to have a struct as a mask input to a Model Reference. I will have multiple identical model references in my model. When I currently try to modify the mask parameter to use a struct, I get the following error:
"Variable 'blah' has ben deleted from the base workspace."
The struct contains information for a large number of blocks and I am trying to have the blocks extract the information from the struct in the normal way (e.g., Block param: blah.field.block_param_value).
Everything works if I have the struct defined in the base workspace and then have the sub-model (used by the model reference) use that directly. However, this does not allow me to use multiple identical model references because they would all point to the same struct in the base workspace.
I have looked at a number of other posted questions asking about this issue and have read that this is possible but without in-depth information as to how.
The following asks this but the answer does not work for me-
This references it but was never answered-
Other resources suggest using a non-virtual bus, but I am unsure how that accomplishes this goal if I'd like to access the fields in a struct-like fashion.
Very much appreciate the help ahead of time :)
4 Comments
Paul
on 6 Jan 2024
Hi Prestonr,
I'd like to make sure I understand the problem.
Let's say we have a model called child.slx. child.slx contains, let's say, two blocks. Each block has one block parameter, and the parameter in the dialog for the first block is blah.field.value1 and the parameter in the dialog for the second block is blah.field.value2, where blah is a struct.
The goal is to be able to have child.slx be referenced (more than once) from a top model, let's call it parent.slx. And we want each instance of child.slx to get its own struct input passed down from parent, i.e., blah1 and blah2, such that the field values of blah1 and blah2 are used as the block parameters child1 and child2 respectively.
Is that correct?
Prestonr
on 6 Jan 2024
Paul
on 6 Jan 2024
Is masking the Model block a requirement?
Prestonr
on 6 Jan 2024
Accepted Answer
More Answers (1)
madhan ravi
on 6 Jan 2024
0 votes
Use one of the approaches mentioned in the link:
Categories
Find more on Interactive Model Editing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!