{"id":1454,"date":"2012-11-07T04:00:01","date_gmt":"2012-11-07T09:00:01","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/?p=1454"},"modified":"2017-01-04T15:37:46","modified_gmt":"2017-01-04T20:37:46","slug":"new-options-for-debugging-in-r2012b","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2012\/11\/07\/new-options-for-debugging-in-r2012b\/","title":{"rendered":"New options for debugging in R2012b"},"content":{"rendered":"<p>Today I want to highlight R2012b features very useful when debugging a model.<\/p>\r\n\r\n<p>Using the simulation stepping and <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/stepping-through-a-simulation.html#btj2bl1\">conditional breakpoints<\/a>, you should be able to run your simulation up to a certain point and move back and forth in time around this point to test things without re-running the entire simulation.<\/p>\r\n\r\n<p><strong>Simulation Stepper<\/strong><\/p>\r\n\r\n<p>You probably noticed that the Simulink toolbar now has 2 new buttons to step forward and backward:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q4\/stepper_toolbar.png\" alt=\"Stepper toolbar\" \/><\/p>\r\n\r\n<p>To use this feature efficiently, I think it is important to understand how it works.<\/p>\r\n\r\n<p>On one side, the <em>next step<\/em> button is obvious. Pushing it makes the simulation move forward by one step.<\/p>\r\n\r\n<p>Moving backward involves a bit more. Just like with your DVR (or VCR as I first wrote), to go backward data must be recorded. Under the hood, the simulation stepper saves snapshots of the simulation using <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/saving-and-restoring-the-simulation-state-as-the-simstate.html\">SimState<\/a>.<\/p>\r\n\r\n<p>When you click the <em>previous step<\/em> button for the first time, a dialog opens:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q4\/stepper_configuration.png\" alt=\"Stepper configuration dialog\" \/><\/p>\r\n\r\n<p>In this dialog, you can specify how many previous snapshots are saved and the number of major steps between those snapshots. Based on the size of your model, you need to choose numbers that avoid using too much memory or saving snapshots too frequently that might slow down your simulation.<\/p>\r\n\r\n<p><strong>Breakpoints<\/strong><\/p>\r\n\r\n<p>Before stepping backward, you first need to run and then pause the simulation. This can be done with breakpoints.\r\n\r\n<p>To pause at a specific simulation time, you can use the dialog shown above.<\/p>\r\n\r\n<p>What is more interesting is to break based on signals values. When you right-click on a signal line, you can add conditional breakpoints:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q4\/AddConditionalBreakPoint.png\" alt=\"Stepper toolbar\" \/><\/p>\r\n\r\n<p>You define the conditions for the breakpoint:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q4\/breakpointDialog.png\" alt=\"Stepper toolbar\" \/><\/p>\r\n\r\n<p>Of course, you can add multiple conditions for the same signal. Once you added all your breakpoints, you can manage them by clicking on the breakpoint icon next to the line:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2012Q4\/manage_breakpoints.png\" alt=\"Stepper toolbar\" \/><\/p>\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\n<p>Look at the documentation for a detailed example of <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/stepping-through-a-simulation.html\">Stepping Through a Simulation<\/a> and let us know what you think of this new debugging technique by leaving a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=1454&#comment\">comment here<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Today I want to highlight R2012b features very useful when debugging a model.\r\n\r\nUsing the simulation stepping and conditional breakpoints, you should be able to run your simulation up to a certain... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2012\/11\/07\/new-options-for-debugging-in-r2012b\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[43,11,16],"tags":[451,294],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/1454"}],"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=1454"}],"version-history":[{"count":34,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/1454\/revisions"}],"predecessor-version":[{"id":6246,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/1454\/revisions\/6246"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=1454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=1454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=1454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}