在simuli万博1manbetxnk上的家伙

万博1manbetx基于Simulink和模型的设计

Creating Custom Gauges

This week, I have a gift for you!

由于Matlab R2020B中添加的新功能,我创建了一个自定义仪表库,您可以添加到Simulink模型并将其发布到万博1manbetxMATLAB CentralGitHub

Here is what my collection of gauges looks like, all together in action:

定制仪表库

Let's look at a few examples illustrating how you can create such custom gauges yourself.

示例1:电池充电状态

这是一个动画,展示我如何创建上面所示的电池测量仪的电池状态。我经历过的步骤可以总结为:

  1. Add avertical gauge到模型
  2. Connect the vertical gauge to the signal of interest, the output of the Sine Wave block in this case
  3. Select the gauge in the canvas and in the Property Inspector, click Edit Design in the Design tab
  4. Remove the default needle image (my battery does not need a needle)
  5. Replace the default background by ascalable vector graphics (SVG)image. Note that I used Microsoft PowerPoint to create this image and saved it inSVG格式
  6. 在刻度子菜单中,我禁用刻度,跨度线和标签,因为我不需要电池
  7. In the Value Bar sub-menu, I used the Value Preview to see how the Value Bar looks for different values and I adjusted its dimensions to fit my background image

创建定制电池垂直仪表

Example 2: Bouncing Ball

For this second example, I created a gauge to animate ourbouncing ball example。在添加垂直仪表并将其连接到所需的信号后,i:

  1. Replaced the default image with a "ground" on which the ball will bounce. As in the previous case, I created the SVG image using Microsoft PowerPoint and saved it in SVG format
  2. 指定了刻度,跨度线和标签的所需颜色
  3. Positioned and resized the scale
  4. 用我创建的球图像替换针图像
  5. 确认一切都按预期使用值预览移动

Creating a custom bouncing ball gauge

Example 3: Gate Valve

In this third example, I want to highlight how you can use a foreground image to create a mask on top of the value bar. This allows creating, for example, a circular hole that opens and closes. After adding the gauge and connecting it to a signal I:

  1. Removed background image, needle image, ticks, span line, and labels
  2. Positioned and resized the scale
  3. 添加了一个透明孔的前景图像
  4. 确认一切都按预期使用值预览移动

创建自定义门阀仪

Note that in all those examples I used模拟Pacingto slow down the simulation such that we can see the gauges being animated at a reasonable speed.

现在轮到你了

Download my library of custom gauges fromMATLAB Central要么Github,或尝试在Matlab R2020B中创建自己的自定义仪表。让我们知道它是如何进入下面的评论。

|

评论

要发表评论,请点击此处登录到您的 MathWorks 帐户或创建一个新帐户。