Simulink problem - To workspace and from workspace

Simulink problem - To workspace and from workspace

Post by YZ W » Sat, 10 Oct 2009 02:12:03


Hi,
I have built a model A, which has two copmonents: A1 and A2. A1's outputs is A2's inputs, and A1 has its inputs from A2's feedback. Simulating this model, I can get correct results.

Then, I output the A1's outputs bus signals to a ToWorkspace variable named bus_out with time stamp. Simulating the model again, now I can get the bus_out signal data.

Then, I delete the connection between A1 and A2. Now, I use the bus_out and define a new variable named bus_in as a Fromworkspace variable, and use bus_in as the A2's inputs. Simulating the model, now I get a quite differrent results!

Why?
 
 
 

Simulink problem - To workspace and from workspace

Post by Phil Godda » Sat, 10 Oct 2009 07:51:01

Because, as per the doc, To Workspace only writes data to the workspace when the simulation is paused or terminated.
Because of that, using a To Workspace then a From Workspace block is not going to give you the same results as connecting the blocks together with a line.

You also need to ensure that the data being written by the To Workspace block is in a format acceptable to the From Workspace block.
As per the doc, if you are writing/reading matrix data then you need to transpose the data being written by the To Workspace block before using it in a From Workspace block.
However I'm not sure if this needs to be considered when using bus blocks.

Phil.