Richard is a Consulting Engineer at MathWorks focused on the Embedded Coder product for code generation, primarily in the Aerospace industry.
Richard’s pick this week is 3DScope by Giampiero Campa.
As an engineer, I spend a lot of time analyzing data. This usually involves looking at a lot of plots to determine how a system is behaving. In Simulink, there are a number of options for doing this. You can log the desired signals to post process after a simulation, you can stream selected signals to the Simulation Data Inspector or a scope to see a time history as the simulation executes. While these can be quite useful, they are limited in that they show signals vs. time. Quite often, we need to look at how signals relate to each other. The Simulink X-Y Graph block in the Sinks library provides the capability of plotting two signals. However, we live in a three dimensional world and only being able to contrast two signals at a time is limiting. Consider the simple model below with three sine waves:
Looking at the three plots below, it is hard to tell what the actual system response is.
In the past, to overcome this, you would need to log the data and then post-process it in MATLAB to generate the 3D plot. To address this limitation, Giampiero has created a custom 3DScope block that extends the X-Y Graph block to three dimensions. This allows you to visualize the interaction of three signals while the simulation is running.
Consider the previous model reconfigured to replace the three X-Y Graph blocks with Giampiero’s 3DScope block:
As you can see, this three dimensional plot provides much greater insight into the behavior of the system.
To control how the plot looks, there are a number of parameters the user can set:
These allow you to specify not only the limits on the axes but also the viewpoint for the plot as well as the line style and whether to include line markers and a grid. Giampiero’s block is not just limited to a single set of three signals as shown previously but by specifying the “Number of point (lines)” parameter, multiple sets can be plotted as shown below:
There are a number of enhancements that i would like to see Giampiero make to this block:
- Make the figure active so the user can change the viewpoint.
- Allow the user to specify a line marker for the current location. This would help the user to see the current data point and provide a moving reference.
- Allow the user to specify the number of time steps to plot (vs. all time steps). This would reduce the clutter for long simulations.
These enhancements would make the 3DScope block function similarly to the comet3 plot in MATLAB.
Giampiero’s 3DScope block provides an additional visualization tool to aid in understanding the behavior of your system. Give it a try and let us know what you think here or leave a comment for Giampiero.
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.