Matlab中如何添加自己的模塊庫(Library)

Matlab中如何添加自己的模塊庫(Library)

  1. 使用程序幫助
  2. 一、按“F1”或者選擇菜單項中的“Help”並打開“Product Help”
  3. 二、找到“搜索”,並搜索“slblocks.m”
  4. 三、按照說明即可添加

或者

  1. 不使用幫助進行添加
  2. 先建立自己的“Library”,並保存
  3. 新建一個“M文件”並保存到“Library”的文件夾中
內容如下:
function blkStruct = slblocks

%SLBLOCKS Defines a block library.

% Library's name. The name appears in the Library Browser's

% contents pane.

blkStruct.Name = ['My' sprintf('\n') 'Library'];

% The function that will be called when the user double-clicks on

% the library's name. ;

blkStruct.OpenFcn = 'mylib';

% The argument to be set as the Mask Display for the subsystem. You

% may comment this line out if no specific mask is desired.

% Example: blkStruct.MaskDisplay =

'plot([0:2*pi],sin([0:2*pi]));';

% No display for now.

% blkStruct.MaskDisplay = '';

% End of blocks

三、可將上面的 My Library 改成自己想在“Simulink”中顯示的 “庫名稱”

將 綠色字符 改成自己所建的 “Library”的名稱四、添加庫文件所在的文件夾路徑到“Matlab”的搜索路徑中:

1、打開菜單項“文件(File)”,選擇“設置路徑(Set Path)”並進行添加

或者

2、在“Command Window”中輸入“pathtool”,然後添加


分享到:


相關文章: