MATLAB Answers

Hs5555
0

Assign to simulink input in State Flow

Hs5555
さんによって質問されました 2018 年 10 月 23 日
最新アクティビティ Arunkumar M さんによって 回答されました 2018 年 11 月 13 日
My state flow accepts variables from Workspace as Inputs.
In one of the stateflow state blocks, there is a function call (which I wrote in matlab). This function receives those Inputs as arguments, modifies them during the run and returns them because I intend to pass them to other functions that are invoked in other states.
However, I get the following error:
Attempted to assign to simulink input.
I would appreciate any help to overcome this problem.

  2 件のコメント

TAB
2018 年 10 月 23 日
Please post the code/part of code/example code with your question.
It will be easy to understand what you want to do.
Hs5555
2018 年 10 月 23 日
variable a is located at the workspace. In the state flow window there is a state that receives the a variable as an input. In one of the states, under the entry part, I wrote a function call:
[a] = FuncA(a);
this function receives variable a as an argument, assign a new value to it and returns it.
When I press run in the stateflow window, the diagnostic viewer window pops and gives the error message I mentioned above.
I guess that I cannot assign to an input that the stateflow receives so my questions are:
how should I define variable a in the stateflow so I can:
1. get its initial value from the workspace
and
2. modify it inside the stateflow in a way that it will be updated in the workspace?
I hope its much more clear now. thanks!

サインイン to comment.

タグ

製品


リリース

R2017b

1 件の回答

回答者: Arunkumar M 2018 年 11 月 13 日

I think what you want to do is to start with the input value and then overwrite the input value later during simulation.
You can try one of the two methods:
  1. assign a temporary variable say b in entry action (en: b = a), where a is your input variable. Later you can modify b and can use b also in your transition conditions. But in this, the variable a remains untouched
  2. since your input variable a is stored in workspace, you can overwrite the variable a in workspace through assignin command. This lets your simulation to take the updated value from the next time step.

  0 件のコメント

サインイン to comment.



Translated by