zoukankan      html  css  js  c++  java
  • 在Simulink中创建库

    将Simulink中常用的block放入一个创建的库中,调用起来会很方便。 本篇将介绍创建Simulink库的基本方法。

    1. 创建库

    库的创建方法和Simulink模型非常相似。第一步是在库浏览器(Library Browser)的菜单中,选中File→New→Library。

    simulink_CreateNewLibrary

    在弹出的创建库窗口,添加该库的blocks。

    Blocks Added to a New Library.

    命名并保存该库到当前目录。

    2. 添加库到Library Browser

    找到matlabroot/toolbox/simulink/blocks/slblocks.m, 将该文件复制到当前目录。

    或直接在当前目录中创建slblocks.m, 内容如下:

    function blkStruct = slblocks 
    % Function to add a specific custom library to the Library Browser 
    
    % Author: Phil Goddard (phil@goddardconsulting.ca) 
    
    % Define how the custom library is displayed in the Library Browser 
    Browser.Library = 'customlib'; %库文件的名称 
    Browser.Name    = 'My Custom Library'; %在库浏览器中显示的名称 
    Browser.IsFlat  = 1; % 该库文件是否有子系统等 
    
    % 定义在旧版matlab中的显示方式e 
    blkStruct.Name = ['My Custom' sprintf('\n') 'Library'];  %在库浏览器中显示的名称 
    blkStruct.OpenFcn = 'customlib'; % Name of the .mdl file   %库文件的名称 
    blkStruct.MaskDisplay = ''; 
    
    % 输出创建的Browse到Simulink库浏览器 
    blkStruct.Browser = Browser;

    3. 显示库

    将当前目录添加到MATLAB的路径中: File->Set path->Add Folder->Save;

    重启MATLAB,在Simulink的库浏览器中,即可找到刚所创建的库。

    simulink_CustomLibraryBrowser

  • 相关阅读:
    nginx:安装成windows服务
    org.aspectj.apache.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 18
    数据库中间件
    架构策略
    谈判
    设计模式 总结 常用10种
    08 状态模式 state
    07 策略模式 strategy
    06 命令模式(不用)
    05 观察者模式 Observer
  • 原文地址:https://www.cnblogs.com/xpvincent/p/2890769.html
Copyright © 2011-2022 走看看