Guy on Simulink

Simulink & Model-Based Design

Visualizing Simscape data

Blogger, Guy Rouleau By Guy Rouleau

Today I want to introduce one of my favorite submissions on MATLAB Central, the Simscape Simulation Results Viewer.

Working in technical support, I often receive requests from customers asking for help when their custom component created using the Simscape language does not behave as expected. Before Simscape 3.3 (R2010a), the only way to view simulation results from Simscape models was to add sensors to the model, or to add an output signal for each variable in the Simscape language file.

Simscape 3.3 (R2010a) introduced data logging to help debugging. To save simulation results, all you have to do is open the model Configuration Parameters Dialog Box and go to the Simscape section. Once there, enable logging of simulation data, specify the name of the logging variable and how many points you want saved.

Enabling the data logging from the Simulink Configuration Parameters dialog

After simulating the model, the Simscape software creates an object of type simscape.logging.Node in the base workspace. This object contains all the simulation results from the Simscape physical network and you can extract that data as explained in the Data Logging Example documentation page.

I have to be honest and admit that the first time I tried to extract data from the simscape.logging.Node object I found it a bit complex. I called one of our Simscape developers to ask if there was an easier way to visualize my Simscape data. He told me: "We are working on something!"

That "something" he mentioned is the Simscape Simulation Results Viewer, which can now be downloaded from MATLAB Central.

Simscape Simulation Results Viewer

I have been using this tool for only a few weeks, and it has already saved me a significant amount of time. I strongly recommend anyone using Simscape to try it; I guarantee you will love it. You can see from the image above that a tree viewer helps you navigate the data structure, and when you select a branch of the tree, it plots the data automatically with the name and the units.

One of the best parts about this is that the file exchange submission includes the MATLAB source code. As I work with a lot of engineers who are developing unique systems, I can think of some requests that they would have. They will be able to look at the MATLAB code and enhance the Simscape data logging viewer to meet their needs.

Now it's your turn!

Download this MATLAB Central submission and look at the MATLAB source code. Does that give you ideas to create a similar viewer specific to your application? Leave a comment here and share your thoughts.

  • print


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.