npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@runiq/export-simulink

v1.2.0

Published

Simulink MDL exporter for Runiq Control system block diagrams

Readme

@runiq/export-simulink

Simulink MDL exporter for Runiq Control system block diagrams

Features

  • ✅ Exports block diagrams to Simulink MDL format
  • ✅ Generates .mdl files loadable in MATLAB/Simulink
  • ✅ Converts transfer functions to MATLAB array notation
  • ✅ Supports all block diagram shapes (TransferFcn, Gain, Integrator, etc.)
  • ✅ Automatic block positioning from layout
  • ✅ Proper port connections for signal flow
  • ✅ Professional control system models for MATLAB

Installation

pnpm add @runiq/export-simulink

Usage

import { toSimulink } from '@runiq/export-simulink';
import type { DiagramAst, LaidOutDiagram } from '@runiq/core';

// Your diagram and layout from parser + layout engine
const diagram: DiagramAst = {
  /* ... */
};
const layout: LaidOutDiagram = {
  /* ... */
};

// Export to Simulink MDL
const result = toSimulink(diagram, layout);

// result.mdl contains the complete MDL file content
console.log(result.mdl);

// Check for warnings
if (result.warnings.length > 0) {
  console.warn('Warnings:', result.warnings);
}

Output Example

The exporter generates a Simulink MDL (Model Definition Language) file:

Model {
  Name		"untitled"
  Version		"7.6"
  SavedCharacterEncoding	"UTF-8"

  System {
    Name		"untitled"
    Location		[0, 0, 800, 600]

    Block {
      BlockType		"TransferFcn"
      Name		"tf1"
      Numerator		"[1]"
      Denominator		"[1 1]"
      Position		[100, 50, 180, 110]
      SID		"1"
    }

    Block {
      BlockType		"Gain"
      Name		"g1"
      Gain		"10"
      Position		[200, 50, 260, 90]
      SID		"2"
    }

    Line {
      SrcBlock		"tf1"
      SrcPort		1
      DstBlock		"g1"
      DstPort		1
    }
  }
}

Loading in MATLAB/Simulink

  1. Save the output to a .mdl file:

    import fs from 'fs';
    fs.writeFileSync('control_system.mdl', result.mdl);
  2. Open in MATLAB:

    open_system('control_system.mdl')

Supported Shapes → Simulink Blocks

| Runiq Shape | Simulink Block | Description | | ------------------- | -------------- | -------------------------------------------- | | transfer-fn | TransferFcn | Transfer function with numerator/denominator | | gain | Gain | Amplifier/gain block | | integrator | Integrator | Integration block (1/s) | | differentiator | Derivative | Differentiation block (s) | | time-delay | TransportDelay | Time delay block | | saturation | Saturate | Saturation with limits | | compare-junction | Sum | Summing junction with +/- inputs | | multiply-junction | Product | Multiplication block | | divide-junction | Product | Division block |

Transfer Function Parsing

The exporter automatically parses transfer function labels:

  • "1/(s+1)" → Numerator: [1], Denominator: [1 1]
  • "5/(s^2+3s+2)" → Numerator: [5], Denominator: [1 3 2]
  • "K/(s+1)" → Simple first-order system

For complex polynomials, the exporter provides a best-effort conversion. You may need to adjust coefficients in Simulink for advanced systems.

API

toSimulink(diagram, layout): SimulinkResult

Parameters:

  • diagram (DiagramAst): The diagram AST from parser
  • layout (LaidOutDiagram): The positioned nodes/edges from layout engine

Returns: SimulinkResult

  • mdl (string): Complete MDL file content
  • warnings (string[]): Array of warning messages

Testing

pnpm test       # Run tests
pnpm build      # Build package

Compatibility

  • MATLAB R2010a and later
  • Simulink 7.6 and later
  • MDL format (text-based, not binary SLX)

License

MIT