Creating Custom Gauges
This week, I have a gift for you!
由于Matlab R2020B中添加的新功能,我创建了一个自定义仪表库,您可以添加到Simulink模型并将其发布到万博1manbetxMATLAB Central和GitHub。
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:电池充电状态
这是一个动画,展示我如何创建上面所示的电池测量仪的电池状态。我经历过的步骤可以总结为:
- Add avertical gauge到模型
- Connect the vertical gauge to the signal of interest, the output of the Sine Wave block in this case
- Select the gauge in the canvas and in the Property Inspector, click Edit Design in the Design tab
- Remove the default needle image (my battery does not need a needle)
- Replace the default background by ascalable vector graphics (SVG)image. Note that I used Microsoft PowerPoint to create this image and saved it inSVG格式
- 在刻度子菜单中,我禁用刻度,跨度线和标签,因为我不需要电池
- 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:
- 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
- 指定了刻度,跨度线和标签的所需颜色
- Positioned and resized the scale
- 用我创建的球图像替换针图像
- 确认一切都按预期使用值预览移动
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:
- Removed background image, needle image, ticks, span line, and labels
- Positioned and resized the scale
- 添加了一个透明孔的前景图像
- 确认一切都按预期使用值预览移动
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 帐户或创建一个新帐户。