{"id":11380,"date":"2022-02-04T15:24:04","date_gmt":"2022-02-04T20:24:04","guid":{"rendered":"https:\/\/blogs.mathworks.com\/simulink\/?p=11380"},"modified":"2022-02-25T14:25:04","modified_gmt":"2022-02-25T19:25:04","slug":"leveraging-the-simulink-diagnostics-viewer","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2022\/02\/04\/leveraging-the-simulink-diagnostics-viewer\/","title":{"rendered":"Leveraging The Simulink Diagnostics Viewer"},"content":{"rendered":"<div class = rtcContent><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>I am sure most Simulink users will agree that viewing and analyzing warnings and errors is an important part of working with Simulink models. When simulating models interactively using the play button, all diagnostics are easily noticeable since they appear in the Diagnostics Viewer as they occur.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>On the other hand, many users need to run multiple simulations overnight using the <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2021b\/simulink\/slref\/sim.html\"><span>sim<\/span><\/a><span> command, storing the results to MAT-files for future analysis. When doing so, there is no Diagnostics Viewer automatically popping up to inform you that a simulation triggered warnings. This does not mean that you should be ignoring those, even if a warning does not stop a simulation, this is often sign of an actual problem that should be addressed.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>In this blog post, I will illustrate how to review warnings from a simulation executed through the sim command, both programmatically and interactively using the <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2021b\/simulink\/ug\/diagnose-simulation-errors.html\"><span>Diagnostics Viewer<\/span><\/a><span>.<\/span><\/div><h3  style = 'margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: 700; text-align: left; '><span>Accessing Diagnostics Programmatically<\/span><\/h3><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span> In case you were not aware, all diagnostics are saved in the <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2021b\/simulink\/slref\/simulink.simulationoutput.html\"><span>Simulink.SimulationOutput<\/span><\/a><span> object, as part of the <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2021b\/simulink\/slref\/simulink.simulationmetadata-class.html\"><span>simulation metadata<\/span><\/a><span>. Here is an example of how to access this diagnostic information. First, let's load a SimulationOutput object from a MAT-file:<\/span><\/div><div style=\"background-color: #F7F7F7; margin: 10px 0 10px 0;\"><div class=\"inlineWrapper outputs\"><div  style = 'border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '><span style=\"white-space: pre\"><span >data = load(<\/span><span style=\"color: rgb(160, 32, 240);\">'mySavedData.mat'<\/span><span >)<\/span><\/span><\/div><div  style = 'color: rgb(64, 64, 64); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% \/ auto padding-box border-box; font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234px; '><div class=\"inlineElement eoOutputWrapper embeddedOutputsVariableStringElement\" uid=\"50D4C918\" data-testid=\"output_0\" style=\"width: 1146px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;\"><div class=\"textElement eoOutputContent\" data-width=\"1116\" data-height=\"34\" data-hashorizontaloverflow=\"false\" style=\"max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;\"><div style=\"white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;\"><span class=\"variableNameElement\" style=\"white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;\">data = <span class=\"headerElement\" style=\"white-space: pre; font-style: italic; color: rgb(179, 179, 179); font-size: 12px;\">struct with fields:<\/span><\/span><\/div><div style=\"white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;\">    out: [1\u00d71 Simulink.SimulationOutput]\r\n<\/div><\/div><\/div><\/div><\/div><\/div><div  style = 'margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>and check if it contains any warnings:<\/span><\/div><div style=\"background-color: #F7F7F7; margin: 10px 0 10px 0;\"><div class=\"inlineWrapper outputs\"><div  style = 'border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '><span style=\"white-space: pre\"><span >data.out.SimulationMetadata.ExecutionInfo.WarningDiagnostics<\/span><\/span><\/div><div  style = 'color: rgb(64, 64, 64); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% \/ auto padding-box border-box; font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234px; '><div class=\"inlineElement eoOutputWrapper embeddedOutputsVariableTableElement\" uid=\"1B981B79\" data-testid=\"output_1\" style=\"width: calc(100% - 5px);\"><div class=\"ClientDocument veSpecifier table DataFitToViewport\" id=\"variableeditor_client_Document_0\" widgetid=\"variableeditor_client_Document_0\" tabindex=\"0\"><div class=\"summaryBar\" style=\"font-size: 12px; font-family: Consolas, Inconsolata, Menlo, monospace;\"><span>ans = <\/span><span style=\"color: rgb(179, 179, 179); font-style: normal;\">4\u00d71 struct <\/span><\/div><div id=\"variableeditor_TableViewModel_0\" widgetid=\"variableeditor_TableViewModel_0\" class=\"struct ClientViewDiv hasSummaryBar\" data-viewid=\"__1\" style=\"width: 100%; overflow: auto;\"><table cellspacing=\"0\" style=\"border-spacing: 0px; border-collapse: collapse;\"><thead><tr><th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; text-align: left; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;\"><span>Fields<\/span><\/th><th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;\"><span>Diagnostic<\/span><\/th><th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;\"><span>SimulationPhase<\/span><\/th><th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: center; border: 1px solid rgb(191, 191, 191); background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;\"><span>SimulationTime<\/span><\/th><\/tr><\/thead><tbody><tr><th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;\"><span>1<\/span><\/th><td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;\"><span>1\u00d71&nbsp;MSLDiagnostic<\/span><\/td><td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;\"><span>'Execution'<\/span><\/td><td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: right; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;\"><span>0<\/span><\/td><\/tr><tr><th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;\"><span>2<\/span><\/th><td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;\"><span>1\u00d71&nbsp;MSLDiagnostic<\/span><\/td><td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;\"><span>'Execution'<\/span><\/td><td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: right; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;\"><span>0<\/span><\/td><\/tr><tr><th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;\"><span>3<\/span><\/th><td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;\"><span>1\u00d71&nbsp;MSLDiagnostic<\/span><\/td><td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;\"><span>'Execution'<\/span><\/td><td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: right; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;\"><span>0.4000<\/span><\/td><\/tr><tr><th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;\"><span>4<\/span><\/th><td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;\"><span>1\u00d71&nbsp;MSLDiagnostic<\/span><\/td><td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: left; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;\"><span>'Execution'<\/span><\/td><td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; text-align: right; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial;\"><span>0.4000<\/span><\/td><\/tr><\/tbody><\/table><\/div><\/div><\/div><\/div><\/div><\/div><div  style = 'margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>In this case, we can see that it contains 4 warnings. We can look at the first warning with this line:<\/span><\/div><div style=\"background-color: #F7F7F7; margin: 10px 0 10px 0;\"><div class=\"inlineWrapper outputs\"><div  style = 'border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '><span style=\"white-space: pre\"><span > data.out.SimulationMetadata.ExecutionInfo.WarningDiagnostics(1).Diagnostic<\/span><\/span><\/div><div  style = 'color: rgb(64, 64, 64); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% \/ auto padding-box border-box; font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234px; '><div class=\"inlineElement eoOutputWrapper embeddedOutputsVariableStringElement scrollableOutput\" uid=\"29880A2D\" data-testid=\"output_2\" style=\"width: 1146px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;\"><div class=\"textElement eoOutputContent\" data-width=\"1116\" data-height=\"118\" data-hashorizontaloverflow=\"true\" style=\"max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;\"><div style=\"white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;\"><span class=\"variableNameElement\" style=\"white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;\">ans = <\/span><\/div><div style=\"white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;\">  MSLDiagnostic with properties:\r\n\r\n    identifier: 'Simulink:DataStores:DSReadBeforeWrite'\r\n       message: 'The block 'testMdl\/Data Store Read' is reading from the data store 'testMdl\/Data Store Memory' before any blocks have written to this entire region of memory at time 0.0. For performance reasons, occurrences of this diagnostic for this memory at other simulation time steps will be suppressed.'\r\n         paths: {'testMdl\/Data Store Read'  'testMdl\/Data Store Memory'}\r\n         cause: {0\u00d71 cell}\r\n         stack: [0\u00d71 struct]\r\n<\/div><\/div><\/div><\/div><\/div><\/div><div  style = 'margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>While this API gives access to all the needed information and allows you to build tooling around it, it can be tedious to type all that to see each warning one by one. <\/span><\/div><h3  style = 'margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: 700; text-align: left; '><span>Visualizing Diagnostics in the Diagnostics Viewer<\/span><\/h3><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>To help with that, a few releases ago (in R2020b) we added a function to display all the diagnostics stored in a SimulationOutput object in the Simulink Diagnostics Viewer, exactly like if you had clicked play in the canvas: <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2021b\/simulink\/slref\/sldiagviewer.reportsimulationmetadatadiagnostics.html\"><span>sldiagviewer.reportSimulationMetadataDiagnostics<\/span><\/a><span>.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>If the model is closed, the Diagnostics Viewer will launch standalone:<\/span><\/div><div style=\"background-color: #F7F7F7; margin: 10px 0 10px 0;\"><div class=\"inlineWrapper\"><div  style = 'border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 4px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '><span style=\"white-space: pre\"><span > sldiagviewer.reportSimulationMetadataDiagnostics(data.out);<\/span><\/span><\/div><\/div><\/div><div  style = 'margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/DiagnsosticsViewer_1.png\" width = \"711\" height = \"409\" alt = \"\" style = \"vertical-align: baseline; width: 711px; height: 409px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>If the model is opened, the Diagnostics Viewer will open docked in the model, as if you had simulated the model using the play button from the toolstrip:<\/span><\/div><div style=\"background-color: #F7F7F7; margin: 10px 0 10px 0;\"><div class=\"inlineWrapper\"><div  style = 'border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '><span style=\"white-space: pre\"><span > open_system(data.out.SimulationMetadata.ModelInfo.ModelName);<\/span><\/span><\/div><\/div><div class=\"inlineWrapper\"><div  style = 'border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; font-size: 14px; '><span style=\"white-space: pre\"><span > sldiagviewer.reportSimulationMetadataDiagnostics(data.out);<\/span><\/span><\/div><\/div><\/div><div  style = 'margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/DiagnsosticsViewer_2.png\" width = \"720\" height = \"640\" alt = \"\" style = \"vertical-align: baseline; width: 720px; height: 640px;\"><\/img><\/div><h3  style = 'margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: 700; text-align: left; '><span>More on the Simulink Diagnostics Viewer<\/span><\/h3><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>If you are using the latest version of MATLAB (R2021b), you may have noticed that the Diagnostics Viewer is now docked in the Simulink canvas by default. If you prefer to keep it undocked, there is an option that controls this in the Simulink preferences, or under Diagnostics in the Debug tab:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/DiagnsosticsViewer_3.png\" width = \"533\" height = \"524\" alt = \"\" style = \"vertical-align: baseline; width: 533px; height: 524px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Also, in case you had not noticed, like most panels in the Simulink canvas, the docked Diagnostics Viewer can be moved to the top, bottom, left or right side of the canvas. For example, I often prefer seeing it on the right:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/DiagnsosticsViewer_4.png\" width = \"788\" height = \"512\" alt = \"\" style = \"vertical-align: baseline; width: 788px; height: 512px;\"><\/img><\/div><h3  style = 'margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: 700; text-align: left; '><span>Now it's your turn<\/span><\/h3><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>I recommend going through the <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2021b\/simulink\/diagnostics.html\"><span>Diagnostics<\/span><\/a><span> section of the documentation for more info on this topic.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>In the comments below, I would be curious to hear if you prefer the Diagnostics Viewer docked or undocked, and if docked, where in the canvas you prefer it.<\/span><\/div>\r\n<\/div><script type=\"text\/javascript\">var css = '\/* Styling that is common to warnings and errors is in diagnosticOutput.css *\/.embeddedOutputsErrorElement {    min-height: 18px;    max-height: 550px;} .embeddedOutputsErrorElement .diagnosticMessage-errorType {    overflow: auto;} .embeddedOutputsErrorElement.inlineElement {} .embeddedOutputsErrorElement.rightPaneElement {} \/* Styling that is common to warnings and errors is in diagnosticOutput.css *\/.embeddedOutputsWarningElement {    min-height: 18px;    max-height: 550px;} .embeddedOutputsWarningElement .diagnosticMessage-warningType {    overflow: auto;} .embeddedOutputsWarningElement.inlineElement {} .embeddedOutputsWarningElement.rightPaneElement {} \/* Copyright 2015-2019 The MathWorks, Inc. *\/\/* In this file, styles are not scoped to rtcContainer since they could be in the Dojo Tooltip *\/.diagnosticMessage-wrapper {    font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace;    font-size: 12px;} .diagnosticMessage-wrapper.diagnosticMessage-warningType {    color: rgb(255,100,0);} .diagnosticMessage-wrapper.diagnosticMessage-warningType a {    color: rgb(255,100,0);    text-decoration: underline;} .diagnosticMessage-wrapper.diagnosticMessage-errorType {    color: rgb(230,0,0);} .diagnosticMessage-wrapper.diagnosticMessage-errorType a {    color: rgb(230,0,0);    text-decoration: underline;} .diagnosticMessage-wrapper .diagnosticMessage-messagePart,.diagnosticMessage-wrapper .diagnosticMessage-causePart {    white-space: pre-wrap;} .diagnosticMessage-wrapper .diagnosticMessage-stackPart {    white-space: pre;} .embeddedOutputsTextElement,.embeddedOutputsVariableStringElement {    white-space: pre;    word-wrap:  initial;    min-height: 18px;    max-height: 550px;} .embeddedOutputsTextElement .textElement,.embeddedOutputsVariableStringElement .textElement {    overflow: auto;} .textElement,.rtcDataTipElement .textElement {    padding-top: 3px;} .embeddedOutputsTextElement.inlineElement,.embeddedOutputsVariableStringElement.inlineElement {} .inlineElement .textElement {} .embeddedOutputsTextElement.rightPaneElement,.embeddedOutputsVariableStringElement.rightPaneElement {    min-height: 16px;} .rightPaneElement .textElement {    padding-top: 2px;    padding-left: 9px;} .embeddedOutputsVariableTableElement .ClientViewDiv  table tr {  height: 22px;  white-space: nowrap;} .embeddedOutputsVariableTableElement .ClientViewDiv  table tr td,.embeddedOutputsVariableTableElement .ClientViewDiv  table tr th {  background-color:white;  text-overflow: ellipsis;  font-family: Arial, sans-serif;  font-size: 12px;  overflow : hidden;} .embeddedOutputsVariableTableElement .ClientViewDiv  table tr span {  text-overflow: ellipsis;  padding: 3px;} .embeddedOutputsVariableTableElement .ClientViewDiv  table tr th {    color: rgba(0,0,0,0.5);  padding: 3px;  font-size: 9px;}'; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text\/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }<\/script><a href=\"https:\/\/blogs.mathworks.com\/simulink\/files\/DiagnsosticsViewer.mlx\"><button class=\"btn btn-sm btn_color_blue pull-right add_margin_10\">Download Live Script<\/button><\/a>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/simulink\/files\/DiagnsosticsViewer_4.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>I am sure most Simulink users will agree that viewing and analyzing warnings and errors is an important part of working with Simulink models. When simulating models interactively using the play... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2022\/02\/04\/leveraging-the-simulink-diagnostics-viewer\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":11431,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[15,43,33],"tags":[631],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/11380"}],"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=11380"}],"version-history":[{"count":6,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/11380\/revisions"}],"predecessor-version":[{"id":11575,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/11380\/revisions\/11575"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media\/11431"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=11380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=11380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=11380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}