Matlab中如何新增自己的模組庫(Library)

Matlab中如何新增自己的模組庫(Library)

使用程式幫助

一、按“F1”或者選擇選單項中的“Help”並開啟“Product Help”

二、找到“搜尋”,並搜尋“slblocks。m”

三、按照說明即可新增

或者

不使用幫助進行新增

先建立自己的“Library”,並儲存

新建一個“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”,然後新增