Simulink Conditional Execution with From Workspace Block

Asked by Sriram Narasimhan on 27 Jun 2012
Latest activity Answered by TAB on 28 Jun 2012

I am trying to setup a simple conditional execution where based on a test one of two From Workspace blocks is selected i.e., is test is true then I want to load data1 from workspace while if test is false I want to load data2. My problem is that only data1 or data2 will be present in the workspace (and it will correspond to the test condition). When I try to run the simulation, I get a variable not found error for the missing data1 or data2 even though based on the test condition that From Workspace block will not have to be executed. I was expecting the conditonal input branch execution to take care of this and not bother about the From Workspace block for the condition that will not be run. I have tried to acheive this in many ways including switch block, enabled subsystem, if and if action blocks but everytime I am getting the same issue.

What am I doing wrong and how can I solve this problem?

0 Comments

Sriram Narasimhan

Products

1 Answer

Answer by TAB on 28 Jun 2012

If you are using some block in the model and you are resolving the value in the block form the work-space, then variable must be present in the workspace.

Conditonal input branch execution is performed in optimization stage of the model compilation. Prior to it simulink evaluates the model's block parameter expressions to determine their values. So all the parameters used in the model should be present before compilation is started.

See Model Compilation for more details.

0 Comments

TAB

Contact us