> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/smart-power-simulation-software-sps/example-models/command-based-access-to-sps-examples.md).

# Command-Based Access to SPS Examples

## Command‑Based Access to SPS Examples <a href="#command-based-access-to-sps-examples" id="command-based-access-to-sps-examples"></a>

SPS provides a small API to make the example models:

* **Easy to discover** (browseable by category with tab completion)
* **Fast to open** (one command, no menus)
* **Consistent** (same commands work across all example families)

{% stepper %}
{% step %}

### Overview

SPS examples are exposed through the namespace:

{% code lineNumbers="true" %}

```matlab
sps.Examples
```

{% endcode %}

Under this namespace, examples are grouped by **category** (e.g., Intro, Analysis, PowerConverters, Machines, …). Each example is represented by a lightweight handle object that supports:

* Opening the example model
* Opening the associated documentation

All access is **command‑based** and fully compatible with MATLAB **tab completion**.
{% endstep %}

{% step %}

### Browsing Examples by Category

Start by typing:

{% code lineNumbers="true" %}

```matlab
sps.Examples
```

{% endcode %}

and press **TAB**. MATLAB will list all available categories, for example:

{% code lineNumbers="true" %}

```matlab
Analysis
Control
Doc
Intro
Machines
MotorDrives
PowerConverters
PowerGrid
Renewables
```

{% endcode %}

Each category corresponds to a family of SPS examples

{% code lineNumbers="true" %}

```matlab
sps.Examples.Analysis
```

{% endcode %}

Press **TAB** again to list all analysis‑related examples.
{% endstep %}

{% step %}

### Opening an Example Model <a href="#id-3.-opening-an-example-model" id="id-3.-opening-an-example-model"></a>

To open an example model, call `open` with the example handle:

{% code lineNumbers="true" %}

```matlab
open(sps.Examples.<Category>.<ExampleName>)
```

{% endcode %}

#### Example <a href="#example.1" id="example.1"></a>

{% code lineNumbers="true" %}

```matlab
open(sps.Examples.Analysis.IEEE13NodeTestFeederExample)
```

{% endcode %}

This opens the Simulink model associated with the example.

#### Another Example <a href="#another-example" id="another-example"></a>

{% code lineNumbers="true" %}

```matlab
open(sps.Examples.PowerConverters.SwitchingFunctionConverterExample)
```

{% endcode %}

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-960891339523fb90943fc6c249816f7699a22da1%2FSpsExamples01.gif?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Opening Example Documentation

Most examples include an associated documentation page.

To open the documentation:

{% code lineNumbers="true" %}

```matlab
doc(sps.Examples.<Category>.<ExampleName>)
```

{% endcode %}

#### Example <a href="#example.2" id="example.2"></a>

{% code lineNumbers="true" %}

```matlab
doc(sps.Examples.Analysis.LoadFlow5BusNetworkExample)
```

{% endcode %}

This opens the documentation describing the example, theory, and usage.

{% hint style="info" %}
If an example does not define documentation, an informative error is displayed.
{% endhint %}
{% endstep %}

{% step %}

### Accessing Documentation by Model Name

In some workflows, you may know the **model name** (e.g., `power_AveragedPulses.slx`) but not the example name or category.

You can open documentation directly using:

{% code lineNumbers="true" %}

```matlab
sps.Catalog.openDocByModel(<modelName>)
```

{% endcode %}

#### Example <a href="#example.3" id="example.3"></a>

{% code lineNumbers="true" %}

```matlab
sps.Catalog.openDocByModel("power_AveragedPulses.slx")
```

{% endcode %}

This command:

1. Searches the SPS catalog for the example whose `Model` matches the given name
2. Opens the associated documentation

This is especially useful when navigating from models, scripts, or error messages.
{% endstep %}

{% step %}

### Listing and Searching Examples <a href="#id-6.-listing-and-searching-examples" id="id-6.-listing-and-searching-examples"></a>

#### List All Examples <a href="#list-all-examples" id="list-all-examples"></a>

{% code lineNumbers="true" %}

```matlab
sps.Catalog.list
```

{% endcode %}

Returns a table with all examples, including:

* Category
* Name
* Model
* Title
* Documentation availability

#### List Examples in a Category <a href="#list-examples-in-a-category" id="list-examples-in-a-category"></a>

{% code overflow="wrap" lineNumbers="true" %}

```matlab
sps.Catalog.list("Analysis")
```

{% endcode %}

{% code lineNumbers="true" %}

```matlab
      Category                      Name                                 Model                                                         Title                                        
    ____________    _____________________________________    ______________________________    _____________________________________________________________________________________

    {'Analysis'}    {'IEEE13NodeTestFeederExample'      }    {'power_13NodeTestFeeder.slx'}    {'IEEE 13 Node Test Feeder'                                                         }
    {'Analysis'}    {'LoadFlow5BusNetworkExample'       }    {'power_LFnetwork_5bus.slx'  }    {'Initializing a 5-Bus Network with the Load Flow Tool of Powergui'                 }
    {'Analysis'}    {'LoadFlow29BusNetworkExample'      }    {'power_LFnetwork_29bus.slx' }    {'Initializing a 29-Bus, 7-Power Plant Network with the Load Flow Tool of Powergui' }
    {'Analysis'}    {'CoupledCablesExample'             }    {'power_cable.slx'           }    {'Four Coupled 66-kV Cables'                                                        }
    {'Analysis'}    {'SimulinkInterfaceExample'         }    {'power_SLmodeling.slx'      }    {'Interfacing Simulink Models with SPS'                                             }
    {'Analysis'}    {'SimscapeInterfaceExample'         }    {'power_SSCmodeling.slx'     }    {'Interfacing Simscape Models with SPS'                                             }
    {'Analysis'}    {'BuckConverterInterpolationExample'}    {'power_buck.slx'            }    {'Increased Accuracy and Simulation Speed Using Interpolation'                      }
    {'Analysis'}    {'DecoupledPVArrayGridExample'      }    {'power_PVarray_Grid.slx'    }    {'Running a Grid-Connected PV Array Model in Real-Time Using Decoupling Line Blocks'}
```

{% endcode %}

#### Search by Keyword <a href="#search-by-keyword" id="search-by-keyword"></a>

{% code lineNumbers="true" %}

```matlab
sps.Catalog.search("average")
```

{% endcode %}

{% code lineNumbers="true" %}

```matlab
     Category                        Model                                     Name                                                               Title                                        
    ___________________    _________________________________    __________________________________________    _____________________________________________________________________________________
    {'PowerConverters'}    {'power_AveragedPulses.slx'     }    {'SwitchingFunctionConverterExample'     }    {'Switching Function Converter Controlled by Averaged Firing Pulses'                }
    {'PowerConverters'}    {'power_converters.slx'         }    {'PowerConvertersExample'                }    {'Power Converters Modeling Techniques'                                             }
    {'PowerGrid'      }    {'power_hvdc12pulse_average.slx'}    {'HVDCAverageModelExample'               }    {'Thyristor-Based HVDC Transmission System Average Model'                           }
    {'PowerGrid'      }    {'power_dstatcom_avg.slx'       }    {'DistributionSTATCOMAverageModelExample'}    {'D-STATCOM Average Model'                                                          }
    {'Renewables'     }    {'power_PVarray_grid_avg.slx'   }    {'PVArrayGridAverageModelExample'        }    {'Average Model of a 100-kW Grid-Connected PV Array'                                }
    {'Renewables'     }    {'power_wind_dfig_avg.slx'      }    {'WindFarmDFIGAverageModelExample'       }    {'Wind Farm - Doubly-Fed Induction Generator (DFIG) Average Model'                  }
    {'Renewables'     }    {'power_wind_type_4_avg.slx'    }    {'WindFarmType4AverageModelExample'      }    {'Wind Farm - Synchronous Generator and Full Scale Converter (Type 4) Average Model'}
    {'Doc'            }    {'power_sfavg.slx'              }    {'ThreePhaseVSCModelsComparison'         }    {'Comparing Three-Phase VSC Models (Detailed, Switching-Function and Average)'      }
```

{% endcode %}

Search matches against:

* Category
* Example name
* Title
  {% endstep %}

{% step %}

### Working with Example Handles <a href="#id-7.-working-with-example-handles" id="id-7.-working-with-example-handles"></a>

Each entry under sps.Examples.\<Category>.\<ExampleName> is an **example handle**. You normally do not need to manipulate it directly, but it supports useful behavior:

{% code lineNumbers="true" %}

```matlab
ex = sps.Examples.Intro.SteadyStateAnalysisExample; disp(ex)
```

{% endcode %}

Typical output:

{% code lineNumbers="true" %}

```matlab
Intro/SteadyStateAnalysisExample → power_filter.slx
```

{% endcode %}

You can then reuse the handle:

{% code lineNumbers="true" %}

```matlab
open(ex) doc(ex)
```

{% endcode %}
{% endstep %}

{% step %}

### Examples Across Categories

#### Introductory Examples <a href="#introductory-examples" id="introductory-examples"></a>

{% code lineNumbers="true" %}

```matlab
open(sps.Examples.Intro.SteadyStateAnalysisExample)
```

{% endcode %}

#### Power Converter Examples <a href="#power-converter-examples" id="power-converter-examples"></a>

{% code lineNumbers="true" %}

```matlab
open(sps.Examples.PowerConverters.BoostConverterExample)
```

{% endcode %}

#### Machine Models <a href="#machine-models" id="machine-models"></a>

{% code lineNumbers="true" %}

```matlab
open(sps.Examples.Machines.SynchronousMachineExample)
```

{% endcode %}

#### Grid‑Level Studies <a href="#grid-level-studies" id="grid-level-studies"></a>

{% code lineNumbers="true" %}

```matlab
open(sps.Examples.PowerGrid.HVDCMMCInterconnectionExample)
```

{% endcode %}
{% endstep %}

{% step %}

### Opening the Examples Home Documentation

In addition to opening documentation for individual examples, SPS provides a command to open the **home documentation page** that gives an overview of all SPS example models.

Use the following command:

{% code lineNumbers="true" %}

```matlab
sps.Examples.docHome
```

{% endcode %}

This command opens the main *SPS Example Models* documentation page in your web browser.

This is useful when you want to:

* Explore the full set of available SPS examples
* Discover examples outside your current area
* Navigate documentation visually instead of by comman
  {% endstep %}
  {% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/smart-power-simulation-software-sps/example-models/command-based-access-to-sps-examples.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
