Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Matlab/Simulink interface. Easily create Simulink models from a Matlab script.

License

NotificationsYou must be signed in to change notification settings

gave92/Matsim

Repository files navigation

Matsim

A sleek, intuitive interface for building Simulink models from a Matlab script.
Explore Matsim docs »

Report bug ·Request feature

Matsim is a high level interface to create Simulink models from aMatlab script. Matsim is a wrapper around the standardsimulink API that makes building a simulink model programmatically much faster.

View Matsim on File Exchange logo donate

Key features

  • Automatic layout (no need to specify block positions!)
  • Intuitive interface (you can "add", "subtract", "multiply", ... simulink blocks)
  • Extensible library (easily add new blocks from your custom libraries)
       Source script (.m)       Resulting modelNotes
c = Constant(1)Create a Constant block with value 1
res = a+bCreate an Add block and connect its inputs to blocksa andb
res = [a,b]Create an Mux block and connect its inputs to blocksa andb
res = Max(a,b)Create an MinMax block and connect its inputs to blocksa andb
res = 1 - u1./(u2.*u3)Create a group of simulink blocks that computes a complex expression
Scope(Gain(FromWorkspace('var'),'Gain',0.5))Easily combine blocks

Installation

The automatic layout feature relies onGraphViz, which you need to install separately.

  1. InstallGraphViz and add it to the system PATH
  2. Download and extract the Matsim package (fromFile Exhange or from here)
  3. Add Matsim folder (and subfolders) to the Matlab path

Quick guide

Quick example to get started. For more check thetests folder.

1. Create or load a simulink model

importmatsim.library.*% Import Matsim packagesys=simulation.load('my_model');% Create or load a model named 'my_model'sys.setSolver('Ts',0.01,'DiscreteOnly',true)% Set solver for the modelsys.clear()% Delete all blockssys.show()% Show the model

2. Create blocks

Vx= FromWorkspace('V_x');% Add FromWorkspace and Constant blocksWr= FromWorkspace('W_r');Rr= Constant(0.32);slip=1-Vx./(Wr.*Rr);% Evaluate complex mathematical expressionsys.log(slip,'name','slip')% Log the output of the "slip" blocks= Scope(slip);% Create and open scope blocks.open()

3. Connect and layout the model

sys.layout()% Connect and layout the model

4. Simulate the system

V_x= [0:0.1:10;linspace(5,20,101)]';% Define input variablesW_r= [0:0.1:10;linspace(5,23,101)/0.32]';simOut=sys.run('StopTime',10).Logs;% Simulate the system

© Copyright 2017 - 2019 by Marco Gavelli

About

Matlab/Simulink interface. Easily create Simulink models from a Matlab script.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp