Quickstart
Open the Moving Average example, inspect its diagram, run the included scenario, and compare the response with expected values.
This guide uses the Moving Average example included in Modeloop. The model calculates the average of the current input and its two preceding samples. It introduces causal data flow, stored state, simulation scenarios, and result analysis through a complete model.
The example includes the diagram, signal measurements, and an input scenario. It can be opened directly without creating the blocks or configuring the connections manually.
1. Open the example
Open Moving Average in ModeloopModeloop creates an editable copy of the example in a new project and opens its diagram. The input scenario is copied with the model. Existing projects remain available.
On your first visit, the example opens directly in your guest workspace. Opening Modeloop directly starts you with Moving Average. Follow the canvas guide to run the model and inspect a signal in PlotLab. You can edit models and try other examples during your three guest simulation runs.
The link opens the browser application, which includes a results viewer. The same model is available in the desktop example library under Beginner.
2. Inspect the diagram
The figure represents the connections in the included model. Arrows indicate the direction of signal flow.
| Element | Function |
|---|---|
Model Input in |
Supplies the current input sample |
| First Unit Delay | Stores the preceding input sample |
| Second Unit Delay | Stores the input from two executions earlier |
| Sum | Adds the three samples |
| Constant | Defines the divisor as 3 |
| Multiply configured for division | Divides the sum by the constant |
Model Output out |
Exposes the calculated average |
Both Unit Delay blocks have an initial value of zero. The first calculation therefore uses the current input and two zeros. From the third execution onward, all three terms come from the input sequence.
The diagram labels the input signal valueK, its delayed values valueK_1 and valueK_2, and the average movingAverage.
3. Review the included scenario
- Switch the editor from Edit to Testing.
- Select MIL in the testing panel.
- Open Scenarios and select
Scenario_1. - Expand the input
into inspect its Ramp profile.
| Setting | Included value |
|---|---|
| Start Value | 1.0 |
| End Value | 2.0 |
| Start Time | 0.0 s |
| End Time | 1.0 s |
| Duration | 10.0 s |
The input starts at one, increases linearly to two during the first second, and then remains at two. The scenario is already saved with the example.
4. Run the model
- Wait for MIL preparation to complete, then select Run in the canvas toolbar.
- Confirm that the dialog identifies
Scenario_1. - Set Start Time to
0, Stop Time to10, and Step Size to0.01seconds. - Select Run Simulation.
- When execution completes, select Open Results.
The step size gives a sampling interval of 10 milliseconds for this run. Review any reported diagnostics before interpreting the response.
5. Compare the signals
Plot valueK and movingAverage on the same axes in the results viewer. The input rises from one to two. The average initially rises from one third because both stored samples start at zero. During the ramp, it follows the input with a delay introduced by the averaging window. Once all three samples equal two, the output remains at two.
The figure is a mathematical reference calculated from the example’s averaging rule and scenario. It is not a recorded simulation result. Compare the results of the run with the following expected samples.
| Time in seconds | Input | Expected average |
|---|---|---|
0.00 |
1.00 |
Approximately 0.333333 |
0.01 |
1.01 |
0.67 |
0.02 |
1.02 |
1.01 |
1.00 |
2.00 |
1.99 |
1.02 |
2.00 |
2.00 |
Small numerical differences can arise from floating point calculations. The initial rise reflects the configured initial state and should be included when assessing the response.
Continue development
Return to Edit to inspect or change a block parameter. Save the model before returning to Testing, then repeat the simulation to evaluate the change.
To inspect the same model as text, select Edit as text (MDL) in the main toolbar. The text editor shows the model’s interfaces and calculations. Select Suggest to discover the syntax, and apply valid edits to update the diagram. See MDL for the editing workflow and examples.
The included scenario defines inputs but contains no assertions. To turn the exercise into an automated test, use the model testing harness to add expected values and tolerances. See Testing for the available acceptance criteria.
Simulation describes input profiles and result analysis. Modeling Guidelines covers model structure and naming. Code Generation explains how to export an implementation, and Version Control covers recording and reviewing project changes.