> 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/hypersim/model-and-simulation/import-models-from-external-software-or-code/import-from-simulink-hyperlink/export-from-simulink.md).

# Export from Simulink

This page describes how to export a **Simulink model** to be imported into **HYPERSIM** using the Simulink Import tool.

{% stepper %}
{% step %}

### Configure MATLAB for Simulink export to HYPERSIM

Before exporting a Simulink model, MATLAB must be configured to access the Hyperlink code‑generation tools.

1. Start MATLAB.
2. Click **Set Path**.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-087c5640cd9447d3e13b0522dad4993c0d1c5829%2Fsimulink-import-set-path.png?alt=media" alt=""><figcaption></figcaption></figure>

3. Click **Add Folder...** and add the two following directories (replacing **`%version%`** with your installed HYPERSIM version):
   * `C:\OPAL-RT\HYPERSIM\hypersim_`**`%version%`**`\Windows\hyperlink\MATLAB`
   * `C:\OPAL-RT\HYPERSIM\hypersim_`**`%version%`**`\Windows\hyperlink\MATLAB\common`
4. Click **Save**. The Simulink model can now be exported properly for HYPERSIM.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-157dde1054184142a6e28fd977ed31ef0b5312a0%2Fsimulink-import-add-hyperlink.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Configure the System target file in Simulink

1. Open the Simulink model, then open the **Configuration Parameters** dialog.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-14a5133ed8b438ab245150a7ccef0ad8531299bf%2Fsimulink-import-configuration-parameters.png?alt=media" alt=""><figcaption></figcaption></figure>

2. Navigate to **Code Generation**, then click **Browse…** next to **System target file** to select one of the following options.
   * `hyperlink_ert.tlc` for Embedded Coder (recommended when available)
   * `hyperlink_grt.tlc` for Simulink Coder

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-40c750cd72b675744aea0a999a2d7f892369e1be%2Fsimulink-import-system-target-file%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

3. Click **Apply**, then **OK**.

{% hint style="info" %}
These settings persist with the model and only need to be configured once per model.
{% endhint %}
{% endstep %}

{% step %}

### Generate code from Simulink

{% hint style="danger" %}
When exporting a Simulink model, ensure that the **model time step** is explicitly set to the desired value **before generating the code**.

The time step defined in Simulink **must match the simulation time step in HYPERSIM**. A mismatch will prevent the model from running correctly.

It is strongly recommended to **document the selected time step**, for example by including it in the **model name**, to avoid confusion during import and simulation setup.

If multiple time steps are required for the same model, code can be generated for a range of time steps by following the procedure described in [Generate Code for Multiple Time steps](https://www.opal-rt.com/docs/hypersim/model-and-simulation/import-models-from-external-software-or-code/import-from-simulink-hyperlink/export-from-simulink/generate-code-for-multiple-time-step.md).
{% endhint %}

1. Build the code using the method appropriate for your Simulink version. The **Ctrl+B** shortcut is recommended, as it is supported across all versions.
2. Navigate to the appropriate folder within the model directory to locate the generated files:
   * `%model_name%_hyperlink_rtw` (Embedded Coder), or
   * `%model_name%_hyperlink_grt_rtw` (Simulink Coder)

Althought only the `ucm_%model_name%.def` file is selected during the import process in HYPERSIM, **all files in the generated folder are required** for a successful import.

Replace `%model_name%` with the Simulink model name.
{% 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/hypersim/model-and-simulation/import-models-from-external-software-or-code/import-from-simulink-hyperlink/export-from-simulink.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.
