{"id":150,"date":"2011-08-22T20:59:06","date_gmt":"2011-08-22T20:59:06","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/2011\/08\/22\/the-dataset-logging-format\/"},"modified":"2011-08-22T21:04:10","modified_gmt":"2011-08-22T21:04:10","slug":"the-dataset-logging-format","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2011\/08\/22\/the-dataset-logging-format\/","title":{"rendered":"The Dataset logging format"},"content":{"rendered":"<p>Did you notice the new <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/toolbox\/simulink\/rn\/bsrs70g.html#bsrs9zb\"><tt>Dataset<\/tt> logging format<\/a> available in R2011a? \r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q3\/datasetconfig.png\" alt=\"Selecting the Dataset format in the model configuration\"><\/p>\r\n\r\n<p>This new format offers a lot of advantages over the old <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/toolbox\/simulink\/slref\/simulink.modeldatalogs.html\"><tt>ModelDataLogs<\/tt><\/a> format. Here are a few examples.<\/p>\r\n\r\n<p><strong>Timeseries format<\/strong><\/p>\r\n\r\n<p>The <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/toolbox\/simulink\/slref\/simulink.simulationdata.dataset.html\"><tt>Dataset<\/tt><\/a> format uses <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/techdoc\/\/ref\/timeseriesclass.html\">MATLAB timeseries<\/a> objects to store logged data. This allows you to work with logged data in MATLAB without checking out a Simulink license. This also allows you to manipulate the logged data easily using the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/techdoc\/\/ref\/f16-48518.html#f16-48710\">timeseries methods<\/a>, like <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/techdoc\/\/ref\/timeseries.filter.html\"><tt>filter<\/tt><\/a>, <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/techdoc\/\/ref\/timeseries.detrend.html\"><tt>detrend<\/tt><\/a> and <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/techdoc\/\/ref\/timeseries.resample.html\"><tt>resample<\/tt><\/a>.<\/p>\r\n\r\n<p>The first thing to do when your simulation is completed is to look at the signal logged in the <tt>Dataset<\/tt> object. In this example we, kept the default name for this variable: <tt>logsout<\/tt>.<\/p>\r\n\r\n<style type=\"text\/css\">\r\n\r\npre.codeinput {\r\n  background: #EEEEEE;\r\n  padding: 10px;\r\n}\r\n\r\nspan.keyword {color: #0000FF}\r\nspan.comment {color: #228B22}\r\nspan.string {color: #A020F0}\r\nspan.untermstring {color: #B20000}\r\nspan.syscmd {color: #B28C00}\r\n\r\npre.codeoutput {\r\n  color: #666666;\r\n  padding: 10px;\r\n}\r\n<\/style>\r\n\r\n\r\n<pre class=\"codeinput\">\r\nlogsout\r\n<\/pre>\r\n\r\n<pre class=\"codeoutput\">\r\nlogsout = \r\n\r\n  Simulink.SimulationData.Dataset\r\n  Package: Simulink.SimulationData\r\n\r\n  Characteristics:\r\n              Name: 'logsout'\r\n    Total Elements: 2\r\n\r\n  Elements:\r\n    1: 'x1'\r\n    2: 'x2'\r\n\r\n  Use getElement to access elements by index, name or\r\n  block path.\r\n<\/pre>\r\n<br>\r\n\r\n\r\n\r\n<p>If I want to see what <tt>x2<\/tt> look like, I can use the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/techdoc\/\/ref\/timeseries.plot.html\">timeseries plot<\/a> command to quickly observe it:<\/p>\r\n\r\n\r\n<pre class=\"codeinput\">\r\nplot(logsout.getElement(<span class=\"string\">'x2'<\/span>).Values)\r\n<\/pre>\r\n<br>\r\n\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q3\/timeseriespolt.png\" alt=\"Plotting a timeseries\"><\/p>\r\n\r\n<p><strong>Logging multiple data values for a given time step<\/strong><\/p> \r\n\r\n<p>With this feature, you can now log everything happening inside blocks like iterator subsystems and <a href=\"https:\/\/www.mathworks.com\/products\/stateflow\/\">Stateflow <\/a>charts.<\/p>\r\n\r\n<p>If I have this model:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q3\/iteratorlog.png\" alt=\"Model logging data inside a For Iterator Subsystem\"><\/p>\r\n\r\n<p>We can see that the data logged inside the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/toolbox\/simulink\/slref\/foriteratorsubsystem.html\">For Iterator Subsystem<\/a> is different from the one logged outside.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q3\/data_in_out.png\" alt=\"Logging data inside an iterator subsystem\"><\/p>\r\n\r\n<p>This is also very useful for debugging. I already used it to analyze the behavior of multiple <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/toolbox\/simulink\/slref\/datastorewrite.html\">Data Store Write<\/a> blocks writing to the same memory address during one time step.<\/p>\r\n \r\n<p><strong>Simplified access to large-scale simulation data<\/strong><\/p>\r\n\r\n<p>The <tt>Dataset<\/tt> format makes it easier to analyze data from models with deep hierarchies, bus signals, and signals with duplicate or invalid names.<\/p>\r\n\r\n<p>As shown by the examples in the documentation for <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/toolbox\/simulink\/slref\/simulink.simulationdata.dataset.html\"><tt>Simulink.SimulationData.Dataset<\/tt><\/a>, you can use the <tt>getElement<\/tt> method to access individual elements in the <tt>Dataset<\/tt>. You can specify an element by index, name, or block path.<\/p>\r\n\r\n<p><strong>Bug Fixes<\/strong><\/p>\r\n\r\n<p>A number of bugs affecting the <tt>ModelDataLogs<\/tt> format are fixed by the new <tt>Dataset<\/tt> format. Look at <a href=\"https:\/\/www.mathworks.com\/support\/bugreports\/495436\">Bug Report 495436<\/a> for more details.<\/p>\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\n<p>Give a try to the new <tt>Dataset<\/tt> format and let us know what you think by leaving a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=150&amp;#comment\">comment here<\/a>.<\/p>\r\n\r\n\r\n\r\n","protected":false},"excerpt":{"rendered":"<p>Did you notice the new Dataset logging format available in R2011a? \r\n\r\n\r\n\r\nThis new format offers a lot of advantages over the old ModelDataLogs format. Here are a few examples.\r\n\r\nTimeseries... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2011\/08\/22\/the-dataset-logging-format\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[11,33,16],"tags":[214,215,147,213],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/150"}],"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\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=150"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}