{"id":7,"date":"2008-03-18T22:00:42","date_gmt":"2008-03-19T03:00:42","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/2008\/03\/18\/a-historical-tour-of-the-library-browser\/"},"modified":"2017-01-02T20:44:59","modified_gmt":"2017-01-03T01:44:59","slug":"a-historical-tour-of-the-library-browser","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2008\/03\/18\/a-historical-tour-of-the-library-browser\/","title":{"rendered":"A Historical Tour of the Library Browser"},"content":{"rendered":"<p>When I started using Simulink, the libraries were organized a little differently than they are today.  There were fewer blocks and no such thing as a Library Browser.  Take a look at Simulink 1.3c from 1996.<\/p>\r\n\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q1\/Simulink42cLibraryPC.png\" alt=\"The Simulink 1.3c Library\" \/>\r\n\r\n<p>This version was a little before my time.  However, users of that era may remember it.  When I joined The MathWorks in 1998, the Simulink 2 library looked like this.<\/p>\r\n\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q1\/Simulink2libraryPC.png\" alt=\"The Simulink 2 Library\" \/>\r\n\r\n<p>The main challenge with Simulink 2 was screen real estate.  In order to build a model, you had to open each of the sub-libraries in a new window.  First, you would need a Signal Generator, so you open Sources.  Next you need a Unit Delay, so you open the Discrete library.  Then you need a Scope, so you open Sinks, yet another window.  In a short time your desktop would look like this.<\/p>\r\n\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q1\/sl2librariesPC.png\" alt=\"Simulink 2 Libraries on the desktop\" \/><br\/>\r\n<br\/>\r\n<p>In the latter part of 1998 Simulink 3 was introduced.  Along with it came the Library Browser on the PC.  It was revolutionary because you didn't have to clutter your entire desktop with windows to get access to the blocks you needed.  This made a real difference if all you had was an 800x600 pixel monitor.<\/p>\r\n\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q1\/Simulink3LibraryBrowserPC.png\" alt=\"Simulink 3 Library Browser\" \/>\r\n\r\n<p>Unfortunately users on non-Windows platforms were stuck with the old interface.  Even Simulink developers who preferred Linux we relegated to the \"old school\" libraries.  Luckily, screen sizes have continued to increase since the 90s.<\/p>\r\n\r\n<p><b>R2008a<\/b><\/p>\r\n\r\n<p>With the release of R2008a all platforms can now use the same Library Browser.  Our Linux-loving Simulink developers can now use the same great Library Browser we have on the PC.  The Library Browser has a new grid view in addition to the traditional list view.<\/p>\r\n\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q1\/Simulink8aLibraryBrowserPC.png\" alt=\"Simulink R2008a all-platform Library Browser\" \/>\r\n\r\n<p>Notice the search tab, item 1 in the diagram below.  This is an improvement over the old version. When searching, you will now see all the results in one place rather than having to walk through the tree to view each match.  The results are grouped by library and can be collapsed to simplify browsing (2).  The search options (3) also allow for regular expressions.<\/p>\r\n\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q1\/Simulink8aSearchAnnotated.png\" alt=\"Simulink R2008a Library Browser Search Feature\" \/>\r\n\r\n<p>The R2008a Library Browser has improved graphics and better performance compared with previous releases. The old version would redraw all blocks each time you viewed them, and in order to see the blocks in a library it had to be loaded into memory.  The new browser uses caching to improve performance.  The cache also enables faster searches without fully loading all libraries into memory.  By the way, building the cache incurs a one time cost which you may notice the first time you start the Library Browser.<\/p>\r\n\r\n<p>After seeing the new Library Browser, most people ask the same question:<\/p>\r\n\r\n<p><b>But Seth, how do I add my library to the browser?<\/b><\/p>\r\n\r\n<p>It has always been possible to add a library to Simulink.  In order to add a library to the browser, create an <tt>slblocks.m<\/tt> file.  You should store it in the directory with your library. I\u2019m going to use the <a href=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q1\/pidLibrary.mdl\">example library<\/a> from a previous post.  The most basic <a href=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q1\/slblocks.m\"><tt>slblocks.m<\/tt><\/a> file looks like this:<\/p>\r\n\r\n<pre style=\"border: 1px solid rgb(200, 200, 200); padding: 10px; background: rgb(249, 247, 243) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\"><span style=\"color: rgb(0, 0, 255);\">function<\/span> blkStruct = slblocks  \r\n<span style=\"color: rgb(34, 139, 34);\">%SLBLOCKS Defines a block library.  <\/span>\r\n \r\n<span style=\"color: rgb(34, 139, 34);\">% Library's name. The name appears in the Library Browser's  <\/span>\r\n<span style=\"color: rgb(34, 139, 34);\">% contents pane.  <\/span>\r\n \r\nblkStruct.Name = [<span style=\"color: rgb(160, 32, 240);\">'A PID'<\/span> sprintf(<span style=\"color: rgb(160, 32, 240);\">'\\n'<\/span>) <span style=\"color: rgb(160, 32, 240);\">'Library'<\/span>];  \r\n \r\n<span style=\"color: rgb(34, 139, 34);\">% The function that will be called when the user double-clicks on<\/span>\r\n<span style=\"color: rgb(34, 139, 34);\">% the library's name. <\/span>\r\n \r\nblkStruct.OpenFcn = <span style=\"color: rgb(160, 32, 240);\">'pidLibrary'<\/span>;  \r\n \r\n<span style=\"color: rgb(34, 139, 34);\">% The argument to be set as the Mask Display for the subsystem. You<\/span>\r\n<span style=\"color: rgb(34, 139, 34);\">% may comment this line out if no specific mask is desired.  <\/span>\r\n<span style=\"color: rgb(34, 139, 34);\">% Example: blkStruct.MaskDisplay = 'plot([0:2*pi],sin([0:2*pi]));';<\/span>\r\n \r\nblkStruct.MaskDisplay = <span style=\"color: rgb(160, 32, 240);\">''<\/span>;\r\n<span style=\"color: rgb(34, 139, 34);\">% End of blocks<\/span>\r\n<\/pre>\r\n\r\n<p>After creating the library, you will need to select Refresh Tree View from the Library Browser View menu.<\/p>\r\n\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q1\/pidLibraryIn8aBrowserAnnotatedSmall.png\" alt=\"Simulink R2008a Custom Library\" \/><br\/>\r\n\r\n<p>It is also possible to specify multiple libraries within the same <tt>slblocks.m<\/tt>.  I recommend looking at the other <tt>slblocks.m<\/tt> files on your path for examples.<\/p>\r\n\r\n<pre style=\"border: 1px solid rgb(200, 200, 200); padding: 10px; background: rgb(249, 247, 243) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\">\r\n>> which <span style=\"color: rgb(160, 32, 240);\">-all slblocks<\/span>\r\n<\/pre>\r\n\r\n<p>A well-documented example is in <tt>$matlab\/toolbox\/simulink\/blocks\/slblocks.m<\/tt>.  You can start by making a copy of that one and then edit it to reference your library.<\/p>\r\n\r\n<p><b>Try it yourself<\/b><\/p>\r\n\r\n<p>If you have never added a library, try making a library of your most commonly used components.  Select File -> New -> Library from the Library Browser.  Drag in your favorite blocks and add this to the Library Browser to increase your productivity.<\/p>\r\n\r\n<p>Do you have custom libraries?  Are they displayed in the Library Browser? Let me know in the comments.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>When I started using Simulink, the libraries were organized a little differently than they are today.  There were fewer blocks and no such thing as a Library Browser.  Take a look at Simulink 1.3c... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2008\/03\/18\/a-historical-tour-of-the-library-browser\/\">read more >><\/a><\/p>","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,8],"tags":[442,443,9,6,441],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/7"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=7"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/7\/revisions"}],"predecessor-version":[{"id":6212,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/7\/revisions\/6212"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}