技术文章和新闻通讯

Visualizing Simulation Data with Simulink

迈克尔·卡隆(Michael Carone),数学


You know that your Simulink®model has no structural problems because the simulation runs to completion. But how do you know that the system is behaving as it should? To answer this question you need to know what the simulation output looks like throughout the simulation and how changes in system parameters or environmental characteristics affect the system’s response.

With Simulink you have many options for obtaining this information. This article guides you through these options, from tools intended for the early phases of development, when you are still debugging the model, to tools more often used for deeper simulation data analysis.

Port Value Displays – Probe a Signal When Debugging a Model

When debugging a model to isolate a particular issue, you often need to probe a signal or set of signals. To do this in Simulink, you right-click a signal and select “Show Value Label of Selected Port". You can then monitor the value of a particular signal or the value of each element of a bus signal at each time step of the simulation (Figure 1).

Data_Vis_Simulink_fig1_w.jpg
Figure 1. Port Value Display showing four separate bus element values as the simulation runs.

To turn off the visualization you simply right-click the signal again and deselect that option.

Scopes and Other Display Blocks – View Simulation Data Quickly

The Port Value Display gives you the value of a signal at each simulation time step. To see how the values of signals change over time, you add a Scope block (Figure 2). Connect a signal line to a Scope block, run the simulation, and view the data both during and after the simulation.

Data_Vis_Simulink_fig2_w.jpg
图2.带有统计测量的正弦模拟数据,在范围块中查看。

You can add interactive cursors to a Scope block to measure various points on the signal or axes. Signal statistics such as maximum, minimum, and median values can be displayed for a given signal. You can add oscilloscope-like triggers so that the Scope displays a signal or pauses the display when certain events occur.

在信号处理和通信区域内,还有其他几种可视化工具可以添加到模型中以快速查看仿真数据。例如,您可以使用频谱分析仪块在频域中查看数据(图3,左),或使用星座图块查看数字调制信号的星座(图3,右)。

data_vis_金宝appsimulink_fig3_w.jpg
图3. DSP系统工具箱(左)和通信系统工具箱中的星座图(右)在Spectrum Analyzer中查看的仿真数据。

Dashboard Block Library – Tune and Monitor Simulations in One Place

随着设计的进行,您可能需要在模型的顶层设置一个接口,以便您和您的同事可以在一个地方控制和监视模拟。您可以使用图形控件和从仪表板块库中显示(图4)来执行此操作。

Data_Vis_金宝appSimulink_fig4_w_wl.jpg
图4. Simuli金宝appnk仪表板块图形控件和显示器库。

该库包含不同类型的显示器,例如测量值和灯。您可以通过打开显示块并选择要连接到该块的信号或块,将这些显示器与模型中的特定信号联系起来。当模拟运行时,显示屏在模型窗口内连续更新,使您能够一次查看所有重要的仿真数据(图5)。

data_vis_金宝appsimulink_fig5_w.jpg
图5.燃油管理模拟包含了Simulink仪表板块库中的旋钮,开关和仪表。金宝app

仿真数据检查器 - 查看和分析来自多个模拟的数据

当您开发模型时,运行多个模拟以测试不同方案或优化设计参数通常很重要。至此,您可能正在监视数百甚至数千个单独的信号。模拟数据检查器可用于将多个模拟中的所有数据存储在一个地方(图6)。

data_vis_金宝appsimulink_fig6_w.jpg
图6.在模拟数据检查器中比较了两个单独模拟的数据。

然后,您可以比较这些模拟中的所有数据,例如检查一个模拟的信号输出的差异在某个设计公差之内。

MATLAB Graphics – Customize Your Data Analysis and Visualization

Many Simulink visualization tools focus primarily on the time and frequency domains. To view your data in other domains or in a way that is not available in Simulink, you can use MATLAB®. All data produced from Simulink can be accessed within MATLAB for further custom data analysis, either from the command line or through scripts. This data can then be viewed in MATLAB figures and charts (Figure 7).

Data_Vis_Simulink_fig7_w.jpg
图7.绘制foucault pendulum(左)x,y位置的3D直方图(左)和结果图(右)的3D直方图。

专门的可视化工具

到目前为止,我们已经审查了用于一般应用的可视化工具。工具也可用于特定应用程序。例如,当使用Simulink实时™在目标计算机上运行实时仿真时,您可以调整参数并在主机计算机上查看实时仿真数据(图8)。金宝app

data_vis_金宝appsimulink_fig8_w.jpg
Figure 8. Instrumentation to control and monitor real-time simulations.

When tuning control systems, you can plot information such as the poles and zeros of the controller or the Bode response of the model with Simulink Control Design™ (Figure 9).

data_vis_金宝appsimulink_fig9_w.jpg
Figure 9. Bode response for a control system.

此外,为了更好地了解系统在其预期环境中的表现,您可以使用Simmechanics™,带FlightGear的AeroSpace BloveSets™和Simulink 3D Animation™将完整的3D环境连接到Simulink模型(图10)。金宝app

data_vis_金宝appsimulink_fig10_w.jpg
Figure 10. Virtual environment of a vehicle test track, created in Simulink 3D Animation.

概括

Now that you have seen the wide array of visualization tools available throughout the design cycle, be sure to simulate your models often so that you find and remove design flaws as early as possible. Frequent simulations mean that your final implemented system will be better prepared for rigorous verification, validation, and testing.

发布2015-92923V00