# Component arrays in Diagram View

Posted 3 years ago
3091 Views
|
3 Replies
|
2 Total Likes
|
 I have a component array parameter Integer n = 4 myComponentType[n] componentArray And I can set each parameters in the component array with something like parameter Real[n] params myComponentType[n] componentArray(param=params) But this seems very clunky to have to set up a parameter array to specify the individual parameters. I'm sure there's a better way. Additionally, once I turn the component into an array, I lose the ability to change each component's property in Diagram View. I found in "component properties" that there's a checkbox for "array" but it doesn't update the expression editor.Screenshots to illustrate:Array is selected but "n" hasn't evaluated to 4 The parameter array I'm using as a work around is resized to 4 The parameter for the component array is not detected as an array
3 Replies
Sort By:
Posted 3 years ago
 Eric,As mentioned in your other post (resizing arrays) when you make a Class an array, the parameters must be entered as arrays in the form {1,2,3,4,5} (for a one dimensional array). See the model attached to that post to see an example (including setting the parameters from Mathematica)Regards
 Neil,Thanks for the reply. I found my error. By setting the parameters of the component array with a local variable array, I overrode SystemModeler's GUI features. In other words, by trying to work around what I thought was a shortcoming just prevented me from seeing the shortcoming never existed :(So I had subComponent[n] componentArray(param = localParamArray) parameter Real[n] localParamArray which was completely unnecessary. All I needed was subComponent[n] componentArray This is kind of embarrassing and apologize for taking up space on the forums with a noob question. But thanks again for taking the time to respond!