Invalid assignment syntax or parse error for event function (Simbiology)

3 ビュー (過去 30 日間)
BK V
BK V 2021 年 9 月 28 日
コメント済み: BK V 2021 年 10 月 5 日
I am adding an event to a QSP model to impose a function to be a small positive number (say epsilon) if its value goes below epsilon. Snippet of the code is:
f_HPD1 = '((syn_CT.PD1_PDL1+syn_CT.PD1_PDL2)/PD1_50)';
addevent(model, [f_HPD1 '< 1e-10'], [f_HPD1 '= 1e-10']);
Where,
syn_CT is compartment name,
PD1_PDL1, PD1_PDL2 are species in the compartment syn_CT
PD1_50 is model parameter
But I get this error message:
Error using SimBiology.internal.simulate
--> Error reported from Expression Validation:
Invalid assignment syntax or parse error for event function '((syn_CT.PD1_PDL1+syn_CT.PD1_PDL2)/PD1_50) = 1e-10' in event with
trigger '((syn_CT.PD1_PDL1+syn_CT.PD1_PDL2)/PD1_50)< 1e-10'. Event functions must be valid MATLAB expressions and cannot end in
semicolons, commas, comments ('%' and optional text), or line continuations ('...' and optional text).
Error in sbiosimulate (line 140)
simResultsCell = SimBiology.internal.simulate(mobj, cs, variants, doses);
Error in initial_conditions (line 84)
simData = sbiosimulate(model,variant);
Please help me resolve this, any suggestion is really appreciated.
Thank you
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 9 月 28 日
Do you need to use == instead of = ?
BK V
BK V 2021 年 9 月 28 日
No, I am assigning the epsilon (1e-10) values to the H_PD1 function so it should be = and not ==

サインインしてコメントする。

採用された回答

Arthur Goldsipe
Arthur Goldsipe 2021 年 9 月 28 日
Hi,
Events can only assign a value to a component, not to an expression. So your assignment ((syn_CT.PD1_PDL1+syn_CT.PD1_PDL2)/PD1_50) = 1e-10 is invalid because the left-hand side is not a single component name. A valid assignment would look more like syn_CT.PD1_PDL1 = 1e-10. Note that the component on the left-hand side also has to have its Constant property set to false.
Looking at the bigger picture of what you're trying to do, I'm guessing what you might want to do instead is to create a parameter (let's call it HPD1), set its Constant property set to false, and update its value with a repeated assignment rule of the form HPD1 = max(1e-10, ((syn_CT.PD1_PDL1+syn_CT.PD1_PDL2)/PD1_50)).
-Arthur
  9 件のコメント
Arthur Goldsipe
Arthur Goldsipe 2021 年 10 月 5 日
As I mention above, "The warning about 'max' is informational. You will need to manually check that the expression is dimensionally consistent. Once you do that, you can safely ignore this message." The same is true for 'abs'. Unfortunately, SimBiology does not currently have any way to strip the units from expressions or otherwise eliminate this warning. If you want, you can turn this warning off for the duration of your MATLAB session with warning('off', 'SimBiology:DimAnalysisNotDone_MatlabFcn_Dimensionless')
BK V
BK V 2021 年 10 月 5 日
Thank you, I did check the units are consistent so was not sure why do these warnings appear. I cannot turn off the unit conversion since some of the data that we input are in different units and so unit conversion is needed.

サインインしてコメントする。

その他の回答 (0 件)

コミュニティ

その他の回答  SimBiology コミュニティ

カテゴリ

Help Center および File ExchangePerform Sensitivity Analysis についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by