MATLAB Answers

Create a local constant variable that is randomly generated in Simscape Component Code?

1 ビュー (過去 30 日間)
Isaac Perrin
Isaac Perrin 2019 年 8 月 7 日
Answered: Divya Yerraguntla 2019 年 8 月 10 日
I'm working with an array of batteries each represented by the 2RC battery model, and I want to add variability into the internals of the batteries. Is there a way for me to make a variable that is randomly assigned at the initiation of the component and then use the component for the simulation. I tried adding: "var = normrnd(1,0.05)" in the variables section of a resistor and then "R = var*tablelookup(SOC_Table,Temp_Table,R_Table,SOC,T,... " but I got an error since saying this was unsolvable as I had more variables than equations.

  0 件のコメント

サインイン to comment.

件の回答 (1)

Divya Yerraguntla
Divya Yerraguntla 2019 年 8 月 10 日
Hi Isaac,
You could initialise a local variable('var' in your case) as a Model Callback which is executed at specified action points.
Have a look at this link to define 'var' as Model Callback. You could write "var = normrnd(1,0.05)" in the InitFcn(Initialization) Callback and then use it to specify the value 'R' of resistor.
Hope it helps!

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。


Translated by