MATLAB Answers

Read/Write global variables during simulaion

1 view (last 30 days)
Tobias
Tobias on 8 Feb 2011
Hello community,
I am dealing with a tricky issue. First I must admit I have at least basic knowledge of working with Simulink.
My simulation contains of several steps:
1. Initialising variables and values from an external file
2. Starting the simulation, using several custon blocks
Block 1: Read data, process data, write out data
Block 2: Read (maybe former output) data, process data, write out data
...
Block n: Read (maybe former output) data, process data, write out data
3. Report data
My problem is, that all the custom blocks must not be linked (by wire) with each other, because at the moment of creating this simulation it is unclear which input is connected to which output. The assignment shall be able to be parametrised at will.
So I thought of a dynamic way to determine which block shall be "imagninary" connected to each other by using variables for each input and assign the output to it as the init-file specifies. This needs to store data in global variables which can be written by one block (the output block) and be read by zero, one or more blocks. I thought of something like the following in my init file:
B3input1 = B1output2;
B3input2 = B2output1;
My approach to handle this issue via matlab workspace variables failed, because the variables are read once at the beginning of the simulation (and not at the moment I need them to be read). At this time the variables had the "old" value, because at he beginning of the simulation the blocks had no chance to update those values. For this reason I also tried to use the "Goto" and "From" Blocks, but there is no possibility to assign the "Tags" via variables, so I also can't determine dynamically which input belongs to which output.
So now I am looking for another possibility to store and adress my values. In best case I can display those values during my simulation and see how and when they are updated.
Hopefully one of you matlab and simulink gods can please help me.
kind regards, Tobias

Community Treasure Hunt

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

Start Hunting!

Translated by