{"id":151,"date":"2008-08-18T10:00:53","date_gmt":"2008-08-18T15:00:53","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/2008\/08\/18\/when-to-create-classes-in-matlab\/"},"modified":"2016-07-31T13:58:02","modified_gmt":"2016-07-31T18:58:02","slug":"when-to-create-classes-in-matlab","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2008\/08\/18\/when-to-create-classes-in-matlab\/","title":{"rendered":"When to Create Classes in MATLAB"},"content":{"rendered":"<div class=\"content\">\n<p>I\u2019m pleased to introduce today\u2019s guest blogger, Nausheen Moulana. Nausheen manages the teams responsible for the design and<br \/>\ndevelopment of the MATLAB language. She shares her thoughts on when you might want to create classes in MATLAB.<\/p>\n<p>&nbsp;<\/p>\n<h3>Contents<\/h3>\n<div>\n<ul>\n<li><a href=\"#2\">Create a New Data Type<\/a><\/li>\n<li><a href=\"#7\">Manage the Lifecycle of Variables<\/a><\/li>\n<li><a href=\"#11\">Organize Code<\/a><\/li>\n<li><a href=\"#12\">Summary<\/a><\/li>\n<\/ul>\n<\/div>\n<p>The thing I like most about the MATLAB environment is the flexibility I have as a programmer to choose the function\/API that<br \/>\nI think is required for the task at hand. And what's neat is that if I don't find or like what comes \"in-the-box\", I can<br \/>\ncreate my own.<\/p>\n<p>The enhanced <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/object-oriented-programming.html\">object-oriented programming<\/a> capabilities in the R2008a release of MATLAB add some new tools to our programming toolbox. While I can still program with existing tools such as functions and scripts,<br \/>\nhere are some situations where creating a class makes good design sense.<\/p>\n<h3>Create a New Data Type<a name=\"2\"><\/a><\/h3>\n<p>MATLAB, like most programming languages, has a set of primitive data types with a set of operations defined on them. However,<br \/>\nthere are situations when we may need to create our own data type. For example, I might want to use structure arrays to track<br \/>\nemployee information but want to restrict the addition of new fields or modification of the values associated with existing<br \/>\nfields.<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid #c8c8c8;\">employee.age = 23;\r\nemployee.name = <span style=\"color: #a020f0;\">'Jane'<\/span>;\r\nemployee.ID = 17;\r\nemployee(2) = struct(<span style=\"color: #a020f0;\">'age'<\/span>,39,<span style=\"color: #a020f0;\">'name'<\/span>,<span style=\"color: #a020f0;\">'Jerry'<\/span>,<span style=\"color: #a020f0;\">'ID'<\/span>,45);\r\nemployee<\/pre>\n<pre style=\"font-style: oblique;\">employee = \r\n1x2 struct array with fields:\r\n    age\r\n    name\r\n    ID\r\n<\/pre>\n<p>The problem I face is that the fields of structure arrays can be modified easily by assigning new values to them just like<br \/>\nI can modify any variables that store primitive data types.<\/p>\n<p>On the other hand, if the variable <tt>employee<\/tt> is an object, only functions I choose (as creator of the class) can modify the fields.<\/p>\n<p>The ability to control access and modification of data is referred to as <b>encapsulation<\/b>. Designing a class facilitates encapsulation thereby improving the quality of my code since objects are robust to accidental<br \/>\nmodification.<\/p>\n<p>At this point, I'd like to clarify the distinction between classes and objects. Classes are a mechanism to describe interfaces<br \/>\nto the functionality with which users will interact whereas objects are concrete instances of a class with their own data<br \/>\nand related operations. Classes are designed and objects are used.<\/p>\n<p>Another reason I may want to create a new type is to <b>extend or redefine<\/b> operations on an existing type. For example, I may require integer arithmetic to wrap as opposed to saturate (which is what<br \/>\nMATLAB does) on overflow. I may, in addition, require a <tt>sqrt<\/tt> function that works on integers which isn't implemented in MATLAB. I can address these requirements by <tt>subclassing<\/tt> from the appropriate <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/int64.html\"><tt>integer<\/tt><\/a> class in MATLAB and overwriting the arithmetic operations such as <tt>+, -, .*, .\/,<\/tt> <tt>.\\<\/tt> and <tt>.^<\/tt> to wrap on overflow. I can also add a method to my new integer class that computes the <tt>sqrt<\/tt> for integer values. <b>Subclassing<\/b> facilitates <b>code reuse<\/b> thereby eliminating the need to create new capabilities from scratch.<\/p>\n<p><b>NOTE:<\/b> If you do choose to override an arithmetic operator like <tt>plus<\/tt>, be aware that you may have to overload other functions that may use <tt>plus<\/tt> to ensure they give the right answer.<\/p>\n<p>Using MATLAB's external interface APIs and interoperability capabilities, I can <b>connect to external systems<\/b> be they external devices such as data acquisition tools or external libraries created using Java or Component Object Model(COM).<br \/>\nA convenient way to interact with these systems is to design a class that manages data access and modification as well as<br \/>\nprovides sufficient control over the functionality in the external system that I'd like to expose in MATLAB. By designing<br \/>\na class, I will be able to add new behaviors as the libraries I interface with evolve without compromising compatibility.<br \/>\nAlso, if the external system is implicitly object-oriented then designing a class is the more natural way to present it in<br \/>\nMATLAB.<\/p>\n<p>An example in MATLAB of a class which interfaces with an external library is the <tt>timer<\/tt> functionality which uses Java's timer object (<tt>java.util.Timer<\/tt>).<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid #c8c8c8;\"><span style=\"color: #228b22;\">% Create a timer object and set its<\/span>\r\n<span style=\"color: #228b22;\">% execution mode to schedule timer events.<\/span>\r\nt = timer(<span style=\"color: #a020f0;\">'TimerFcn'<\/span>,<span style=\"color: #a020f0;\">'figure;imagesc(magic(5))'<\/span>,<span style=\"color: #a020f0;\">'Period'<\/span>,1);\r\nt.ExecutionMode = <span style=\"color: #a020f0;\">'fixedrate'<\/span>;\r\n<span style=\"color: #228b22;\">% Set name of the timer<\/span>\r\nt.Name = <span style=\"color: #a020f0;\">'MyTimer'<\/span>;\r\n<span style=\"color: #228b22;\">% Set the number of times to execute the callback function.<\/span>\r\n<span style=\"color: #228b22;\">% In this example, the image of magic squares is drawn twice,<\/span>\r\n<span style=\"color: #228b22;\">% once for each of the two events.<\/span>\r\nt.TasksToExecute = 2;\r\n<span style=\"color: #228b22;\">% Start the timer.<\/span>\r\nstart(t)\r\n<span style=\"color: #228b22;\">% Stop and release the timer.<\/span>\r\nstop(t)\r\ndelete(t)<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/151\/objectsblog_01.png\" hspace=\"5\" vspace=\"5\" \/> <img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/151\/objectsblog_02.png\" hspace=\"5\" vspace=\"5\" \/><\/p>\n<p>In this example, designing a class allowed me to <b>reuse<\/b> timer functionality available in Java while giving me the flexibility to present APIs in a manner that is familiar to users<br \/>\ninteracting with objects in MATLAB.<\/p>\n<p>Note that when using new classes written in MATLAB 7.6, I don't need to explicitly call the <tt>delete<\/tt> method to remove an object from memory; MATLAB does this automatically when the object is no longer used. The ability for<br \/>\nan object to <a href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/07\/29\/understanding-object-cleanup\">clean up<\/a>, via the destructor, when MATLAB determines that the object is no longer being used is just one of the many enhancements<br \/>\nto the object-oriented capabilities in MATLAB 7.6.<\/p>\n<h3>Manage the Lifecycle of Variables<a name=\"7\"><\/a><\/h3>\n<p>Generally MATLAB takes care of managing memory for me. For example, create a 50x50 matrix of doubles.<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid #c8c8c8;\">a = rand(50);\r\na = 5;<\/pre>\n<p>With the second assignment to <tt>a<\/tt>, MATLAB takes care of freeing the memory allocated in the previous statement without any user intervention. Whenever variables<br \/>\ngo out of scope, are modified, or are no longer used, MATLAB automatically releases the memory associated with these variables<br \/>\nwhen these variables happen to be primitive types. However, if the variables are resources such as file handles, fonts, or<br \/>\nrepresent other types, then MATLAB needs to transfer control to that object to release resources when the object is no longer<br \/>\nused.<\/p>\n<p>In some situations I may need to take additional action to <b>explicitly manage the lifecycle<\/b> of the variables that get created. By creating class destructors (the <tt>delete<\/tt> method), I can ensure that memory associated with a variable is freed up when the variable is no longer being used. For<br \/>\nexample, let's look at the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/memmapfile.html\"><tt>memmapfile<\/tt><\/a> class in MATLAB. The <tt>memmapfile<\/tt> functionality creates an object that lets me map a file to memory whereby any operations that modify the object in memory<br \/>\nhave the effect of modifying the contents of the file on disk.<\/p>\n<p>Here's how I can map a file named <tt>records.dat<\/tt> to a series of unsigned 32-bit integers and set every other value to zero via the <tt>data<\/tt> property in memory.<\/p>\n<pre>   m = memmapfile('records.dat', 'format', 'uint32', ...\r\n                  'writable', true);\r\n   m.data(1:2:end) = 0;<\/pre>\n<p>Since MATLAB does not explicitly allocate the memory for the data contained in the variable <tt>m<\/tt>, it cannot release the memory either (i.e., in this case, unmapping the mapped region in MATLAB's memory) when the <tt>memmapfile<\/tt> object goes out of scope or is modified via assignment, perhaps in a situation like this.<\/p>\n<pre>   m = rand(4);<\/pre>\n<p>If I exposed the memory mapping functionality directly, I would risk inadvertent memory abuse if users of this class do not<br \/>\nprogrammatically unmap mapped regions. However, an object-oriented approach mitigates this situation since it provides the<br \/>\nclass control over the creation and destruction of objects.<\/p>\n<h3>Organize Code<a name=\"11\"><\/a><\/h3>\n<p><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/classdef.html\">Keywords<\/a> in MATLAB 7.6 allow me to define my class and organize my code in a single M-file. By having <tt>properties<\/tt>, <tt>methods<\/tt>, and <tt>events<\/tt> defined in the same file, I can gain an insight into class data and operations relatively quickly. With methods, I also<br \/>\nhave the flexibility of separating the function definition from implementation. I do so by defining the methods in the file<br \/>\ncontaining the class definition and implementing the methods in separate files. Depending on the number of methods my class<br \/>\nhas, keeping method implementation in separate files can reduce clutter in the class definition.<\/p>\n<h3>Summary<a name=\"12\"><\/a><\/h3>\n<p>MATLAB 7.6 has significant enhancements to object-oriented capabilities that simplify the process of designing classes while<br \/>\nproviding sufficient functionality to handle your most complex class design. When programming, if you find yourself needing<br \/>\nto do any one of the above, then you should consider designing a class. I'd love to hear when you've found creating classes<br \/>\nto be useful. Let me know <a href=\"https:\/\/blogs.mathworks.com\/loren\/?p151#respond\">here<\/a>.<\/p>\n<p><script>\/\/ <![CDATA[\nfunction grabCode_6a5d27b22ccb446f80830d579b3fc0ba() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='6a5d27b22ccb446f80830d579b3fc0ba ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 6a5d27b22ccb446f80830d579b3fc0ba';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        author = 'Loren Shure';\n        copyright = 'Copyright 2008 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('\n\n\n\n\n\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\n\n\n\n\n\n\n\\n');\n      \n      d.title = title + ' (MATLAB code)';\n      d.close();\n      }\n\/\/ ]]><\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;\"><a><span style=\"font-size: x-small; font-style: italic;\">Get<br \/>\nthe MATLAB code<br \/>\n<noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>Published with MATLAB\u00ae 7.6<\/p>\n<\/div>\n<p><!--\n6a5d27b22ccb446f80830d579b3fc0ba ##### SOURCE BEGIN #####\n%% When to Create Classes in MATLAB\n% I\u00e2\u20ac\u2122m pleased to introduce today\u00e2\u20ac\u2122s guest blogger, Nausheen Moulana. Nausheen\n% manages the teams responsible for the design and development of the\n% MATLAB language.  She shares her thoughts on when you might want to\n% create classes in MATLAB.\n\n%%\n% The thing I like most about the MATLAB environment is the flexibility I\n% have as a programmer to choose the function\/API that I think is required\n% for the task at hand.  And what's neat is that if I don't find or like\n% what comes \"in-the-box\", I can create my own.\n%\n% The enhanced\n% <https:\/\/www.mathworks.com\/help\/matlab\/object-oriented-programming.html object-oriented programming> capabilities\n% in the <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/rn\/brga_tq.html R2008a release of MATLAB>\n% add some new tools to our programming toolbox.  While I can still program\n% with existing tools such as functions and scripts, here are some situations\n% where creating a class makes good design sense.\n\n%% Create a New Data Type\n% MATLAB, like most programming languages, has a set of primitive data types\n% with a set of operations defined on them.  However, there are situations\n% when we may need to create our own data type.  For example, I might want\n% to use structure arrays to track employee information but want to\n% restrict the addition of new fields or modification of the values\n% associated with existing fields.\n%\nemployee.age = 23;\nemployee.name = 'Jane';\nemployee.ID = 17;\nemployee(2) = struct('age',39,'name','Jerry','ID',45);\nemployee\n%%\n% The problem I face is that the fields of structure arrays can be\n% modified easily by assigning new values to them just like I can modify\n% any variables that store primitive data types.\n%\n%%\n% On the other hand, if the variable |employee| is an object, only functions\n% I choose (as creator of the class) can modify the fields.\n%\n% The ability to control access and modification of data is referred to as\n% *encapsulation*. Designing a class facilitates encapsulation thereby\n% improving the quality of my code since objects are robust to accidental\n% modification.\n%\n% At this point, I'd like to clarify the distinction between classes and\n% objects.  Classes are a mechanism to describe interfaces to the\n% functionality with which users will interact whereas objects are concrete\n% instances of a class with their own data and related operations.  Classes\n% are designed and objects are used.\n%\n% Another reason I may want to create a new type is to *extend or\n% redefine* operations on an existing type.  For example, I may require\n% integer arithmetic to wrap as opposed to saturate (which is what MATLAB\n% does) on overflow.  I may, in addition, require a |sqrt| function that\n% works on integers which isn't implemented in MATLAB.  I can address\n% these requirements by <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/matlab_oop\/brgze9_-1.html |subclassing|>\n% from the appropriate <https:\/\/www.mathworks.com\/help\/matlab\/ref\/int64.html |integer|> class in\n% MATLAB and overwriting the arithmetic operations such as |+, -, .*, .\/,|\n% |.\\| and |.^| to wrap on overflow.  I can also add a method to my new\n% integer class that computes the |sqrt| for integer values.  *Subclassing*\n% facilitates *code reuse* thereby eliminating the need to create new\n% capabilities from scratch.\n%\n% *NOTE:* If you do choose to override an arithmetic operator like |plus|,\n% be aware that you may have to overload other functions that may use\n% |plus| to ensure they give the right answer.\n%\n% Using MATLAB's external interface APIs and interoperability capabilities,\n% I can *connect to external systems* be they external devices such as data\n% acquisition tools or external libraries created using Java or Component\n% Object Model(COM).  A convenient way to interact with these systems is to\n% design a class that manages data access and modification as well as\n% provides sufficient control over the functionality in the external system\n% that I'd like to expose in MATLAB.  By designing a class, I will be\n% able to add new behaviors as the libraries I interface with evolve\n% without compromising compatibility.  Also, if the external system is\n% implicitly object-oriented then designing a class is the more natural way\n% to present it in MATLAB.\n%\n% An example in MATLAB of a class which interfaces with an external library\n% is the <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/techdoc\/ref\/timer.html |timer|>\n% functionality which uses Java's timer object (|java.util.Timer|).\n%\n%%\n\n% Create a timer object and set its\n% execution mode to schedule timer events.\nt = timer('TimerFcn','figure;imagesc(magic(5))','Period',1);\nt.ExecutionMode = 'fixedrate';\n% Set name of the timer\nt.Name = 'MyTimer';\n% Set the number of times to execute the callback function.\n% In this example, the image of magic squares is drawn twice,\n% once for each of the two events.\nt.TasksToExecute = 2;\n% Start the timer.\nstart(t)\n% Stop and release the timer.\npause(2), stop(t)\ndelete(t)\n%%\n% In this example, designing a class allowed me to *reuse* timer\n% functionality available in Java while giving me the flexibility to\n% present APIs in a manner that is familiar to users interacting with\n% objects in MATLAB.\n%\n% Note that when using new classes written in MATLAB 7.6, I don't need to\n% explicitly call the |delete| method to remove an object from memory;\n% MATLAB does this automatically when the object is no longer used.  The\n% ability for an object to\n% <https:\/\/blogs.mathworks.com\/loren\/2008\/07\/29\/understanding-object-cleanup clean up>,\n% via the destructor, when MATLAB determines that the object is no longer\n% being used is just one of the many enhancements to the object-oriented\n% capabilities in MATLAB 7.6.\n%\n%% Manage the Lifecycle of Variables\n%\n% Generally MATLAB takes care of managing memory for me. For example,\n% create a 50x50 matrix of doubles.\na = rand(50);\na = 5;\n%%\n% With the second assignment to |a|, MATLAB takes care of freeing the\n% memory allocated in the previous statement without any user intervention.\n% Whenever variables go out of scope, are modified, or are no longer used,\n% MATLAB automatically releases the memory associated with these variables\n% when these variables happen to be primitive types.  However, if the\n% variables are resources such as file handles, fonts, or represent other\n% types, then MATLAB needs to transfer control to that object to release\n% resources when the object is no longer used.\n%\n% In some situations I may need to take additional action to\n% *explicitly manage the lifecycle* of the variables that get\n% created. By creating class destructors (the |delete| method), I can ensure\n% that memory associated with a variable is freed up when the variable is no\n% longer being used.  For example, let's look at the <https:\/\/www.mathworks.com\/help\/matlab\/ref\/memmapfile.html |memmapfile|>\n% class in MATLAB. The |memmapfile| functionality creates an object that\n% lets me map a file to memory whereby any operations that modify the\n% object in memory have the effect of modifying the contents of the file on\n% disk.\n%\n%%\n% Here's how I can map a file named |records.dat| to a series of unsigned 32-bit\n% integers and set every other value to zero via the |data| property in\n% memory.\n%\n%     m = memmapfile('records.dat', 'format', 'uint32', ...\n%                    'writable', true);\n%     m.data(1:2:end) = 0;\n%\n%%\n% Since MATLAB does not explicitly allocate the memory for the data contained\n% in the variable |m|, it cannot release the memory either (i.e., in this case,\n% unmapping the mapped region in MATLAB's memory) when the |memmapfile|\n% object goes out of scope or is modified via assignment, perhaps in a\n% situation like this.\n%\n%     m = rand(4);\n%\n% If I exposed the memory mapping functionality directly, I would risk\n% inadvertent memory abuse if users of this class do not programmatically\n% unmap mapped regions.  However, an object-oriented approach mitigates\n% this situation since it provides the class control over the creation and\n% destruction of objects.\n%\n%% Organize Code\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/classdef.html Keywords>\n% in MATLAB 7.6 allow me to define my class and organize my\n% code in a single M-file.  By having |properties|, |methods|, and |events|\n% defined in the same file, I can gain an insight into class data and\n% operations relatively quickly.  With methods, I also have the flexibility\n% of separating the function definition from implementation. I do so by\n% defining the methods in the file containing the class definition and\n% implementing the methods in separate files.  Depending on the number of\n% methods my class has, keeping method implementation in separate files\n% can reduce clutter in the class definition.\n%\n%% Summary\n% MATLAB 7.6 has significant enhancements to object-oriented capabilities\n% that simplify the process of designing classes while providing sufficient\n% functionality to handle your most complex class design.  When programming,\n% if you find yourself needing to do any one of the above, then you should\n% consider designing a class.  I'd love to hear when you've found creating\n% classes to be useful.  Let me know <https:\/\/blogs.mathworks.com\/loren\/?p151#respond here>.\n\n##### SOURCE END ##### 6a5d27b22ccb446f80830d579b3fc0ba\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\nI\u2019m pleased to introduce today\u2019s guest blogger, Nausheen Moulana. Nausheen manages the teams responsible for the design and<br \/>\ndevelopment of the MATLAB language. She shares her thoughts on when you... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/08\/18\/when-to-create-classes-in-matlab\/\">read more >><\/a><\/p>\n","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,6,44],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/151"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/comments?post=151"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/151\/revisions"}],"predecessor-version":[{"id":1841,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/151\/revisions\/1841"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}