1
votes

For a school project I need to create a Simulink model to simulate the behaviour of my prototype.

I made the following model (which is not finished yet), however, I'm new to Matlab and Simulink, and there are a few things I don't understand:

  • Why the if/elseif/else signals are represented as dotted lines and not as solid lines? What does it mean?
  • It seems all the three if/elseif/else statements are executed. I get this type of warning in the Command Window: Warning: The block 'BLOCK NAME' is writing to the data store 'BLOCK NAME' but the block(s) 'BLOCK NAME' have already written to a portion or the entire region of this memory at time 0.0
  • The scope always shows 0 while it should shows 250.

Model: http://pastebin.com/sMrKn2C2

Thank you.

1

1 Answers

4
votes
  • Solid lines represent signal/data flow; dot-dash lines represent Action signals (which control execution of other blocks). The different types are simply to help the reader understand what's going on in the model more quickly than would be the case if all lines were solid.

  • Only one of the If-Action subsystems are executed. (In your case this is the first one). However all three of the Data Store Write blocks are executed. The If-Action subsystems are conditionally executed and hence only execute when their appropriate If condition is true. However everything outside them gets executed at every time step. So the first Data Store Write writes 250, but that gets overwritten with 0 by the second one, which also gets overwritten with 0 by the third one. The warning you are getting is just telling you that multiple blocks are writing to the same memory store at each time step. Typically that is a bad thing.

  • To fix the above issue, and hence to get the correct output writing to the data store and displaying in the scope, do the following,
    enter image description here

The Merge block passes through the last input that was updated, which will correspond to the last If-Action subsystem that was executed, which in turn will be the appropriate true If condition.