Question

I have been searching for a long time and have yet to find a tutorial/answer so I am posting the question here. How can I render a continuous signal within Simulink as a bar graph? The bar graph should be behaving similarly as the native default scope block within Simulink. I.e.: the graph changes in real-time while the signal is running. The same functionality (or close to it) as scope, but in a bar graph format. Any help or directions are appreciated.

Was it helpful?

Solution

There is a Floating Bar Plot in the Simulink Extras->Additional Sinks library. However, it has very limited functionality.

The best way to do this is to write an (m-code) S-Function. Although not difficult, it's not going to be trivial to do properly. Within the S-Function you'll need to do things like

  1. initialize a figure window and an axes on it, and open the figure if it is still open (from a previous simulation).
  2. update the plot (efficiently, and most likely using low level functions, not the bar function itself)
  3. check that the user hasn't closed the figure, and only plot data if it hasn't (or reopen the figure if it has been closed).

You will most likely also need to use some of the block callbacks to do the right thing if the block is deleted (e.g. delete the figure too, if it's still open), copied, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top