{"id":8469,"date":"2017-03-10T09:00:30","date_gmt":"2017-03-10T14:00:30","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=8469"},"modified":"2017-03-10T04:55:13","modified_gmt":"2017-03-10T09:55:13","slug":"3d-scope","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2017\/03\/10\/3d-scope\/","title":{"rendered":"3D Scope"},"content":{"rendered":"\r\n<div class=\"content\"><!--introduction--><p><em>Richard is a Consulting Engineer at MathWorks focused on the Embedded Coder product for code generation, primarily in the Aerospace industry.<\/em><\/p><p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1016860-richard-ruff\">Richard&#8217;s<\/a> pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/4915-3dscope\">3DScope<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1692307-giampiero-campa\">Giampiero Campa<\/a>.<\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#b5b36f07-b5df-4252-a5f5-a08b1e7224ca\">Pick<\/a><\/li><li><a href=\"#d6029044-bd80-4e0e-a908-146c7f3c9025\">Enhancements<\/a><\/li><li><a href=\"#2b6f5a91-b186-4257-9d8a-219bc6abd9d9\">Comments<\/a><\/li><\/ul><\/div><h4>Pick<a name=\"b5b36f07-b5df-4252-a5f5-a08b1e7224ca\"><\/a><\/h4><p>As an engineer, I spend a lot of time analyzing data.  This usually involves looking at a lot of plots to determine how a system is behaving. In Simulink, there are a number of options for doing this.  You can log the desired signals to post process after a simulation, you can stream selected signals to the <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/simulation-data-inspector-overview.html?s_tid=srchtitle\">Simulation Data Inspector<\/a> or a scope to see a time history as the simulation executes.  While these can be quite useful, they are limited in that they show signals vs. time.  Quite often, we need to look at how signals relate to each other.  The Simulink <a title=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/xygraph.html (link no longer works)\">X-Y Graph<\/a> block in the Sinks library provides the capability of plotting two signals.  However, we live in a three dimensional world and only being able to contrast two signals at a time is limiting.  Consider the simple model below with three sine waves:<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_3DScope\/XYGraphModel.png\" alt=\"\"> <\/p><p>Looking at the three plots below, it is hard to tell what the actual system response is.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_3DScope\/XYGraphPlot1.png\" alt=\"\"> <\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_3DScope\/XYGraphPlot2.png\" alt=\"\"> <\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_3DScope\/XYGraphPlot3.png\" alt=\"\"> <\/p><p>In the past, to overcome this, you would need to log the data and then post-process it in MATLAB to generate the 3D plot.  To address this limitation, Giampiero has created a custom 3DScope block that extends the X-Y Graph block to three dimensions.  This allows you to visualize the interaction of three signals while the simulation is running.<\/p><p>Consider the previous model reconfigured to replace the three X-Y Graph blocks with Giampiero&#8217;s 3DScope block:<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_3DScope\/3DScopeModel.png\" alt=\"\"> <\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_3DScope\/3DScopePlot.png\" alt=\"\"> <\/p><p>As you can see, this three dimensional plot provides much greater insight into the behavior of the system.<\/p><p>To control how the plot looks, there are a number of parameters the user can set:<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_3DScope\/3DScopeDialog.png\" alt=\"\"> <\/p><p>These allow you to specify not only the limits on the axes but also the viewpoint for the plot as well as the line style and whether to include line markers and a grid.  Giampiero&#8217;s block is not just limited to a single set of three signals as shown previously but by specifying the &#8220;Number of point (lines)&#8221; parameter, multiple sets can be plotted as shown below:<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_3DScope\/MultipleSignalSetsModel.png\" alt=\"\"> <\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_3DScope\/MultipleSignalSetsPlot.png\" alt=\"\"> <\/p><h4>Enhancements<a name=\"d6029044-bd80-4e0e-a908-146c7f3c9025\"><\/a><\/h4><p>There are a number of enhancements that i would like to see Giampiero make to this block:<\/p><div><ul><li>Make the figure active so the user can change the viewpoint.<\/li><li>Allow the user to specify a line marker for the current location. This would help the user to see the current data point and provide a moving reference.<\/li><li>Allow the user to specify the number of time steps to plot (vs. all time steps).  This would reduce the clutter for long simulations.<\/li><\/ul><\/div><p>These enhancements would make the 3DScope block function similarly to the <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/comet3.html\">comet3<\/a> plot in MATLAB.<\/p><h4>Comments<a name=\"2b6f5a91-b186-4257-9d8a-219bc6abd9d9\"><\/a><\/h4><p>Giampiero&#8217;s 3DScope block provides an additional visualization tool to aid in understanding the behavior of your system. Give it a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=8469#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/4915-3dscope#comments\">comment<\/a> for Giampiero.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_de7ef255ecec4ce18eb4c97b84997cb5() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='de7ef255ecec4ce18eb4c97b84997cb5 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' de7ef255ecec4ce18eb4c97b84997cb5';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2017 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_de7ef255ecec4ce18eb4c97b84997cb5()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2016b<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2016b<br><\/p><\/div><!--\r\nde7ef255ecec4ce18eb4c97b84997cb5 ##### SOURCE BEGIN #####\r\n%% 3DScope\r\n%\r\n% _Richard is a Consulting Engineer at MathWorks focused on the Embedded\r\n% Coder product for code generation, primarily in the Aerospace industry._\r\n% \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1016860-richard-ruff\r\n% Richard's> pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/4915-3dscope 3DScope> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1692307-giampiero-campa\r\n% Giampiero Campa>.\r\n% \r\n%% Pick\r\n% As an engineer, I spend a lot of time analyzing data.  This usually\r\n% involves looking at a lot of plots to determine how a system is behaving.\r\n% In Simulink, there are a number of options for doing this.  You can log\r\n% the desired signals to post process after a simulation, you can stream\r\n% selected signals to the\r\n% <https:\/\/www.mathworks.com\/help\/simulink\/ug\/simulation-data-inspector-overview.html?s_tid=srchtitle\r\n% Simulation Data Inspector> or a scope to see a time history as the\r\n% simulation executes.  While these can be quite useful, they are limited\r\n% in that they show signals vs. time.  Quite often, we need to look at how\r\n% signals relate to each other.  The Simulink\r\n% <https:\/\/www.mathworks.com\/help\/simulink\/slref\/xygraph.html X-Y Graph>\r\n% block in the Sinks library provides the capability of plotting two\r\n% signals.  However, we live in a three dimensional world and only being\r\n% able to contrast two signals at a time is limiting.  Consider the simple\r\n% model below with three sine waves:\r\n%\r\n\r\n%%\r\n% \r\n% <<XYGraphModel.png>>\r\n% \r\n\r\n%% \r\n% Looking at the three plots below, it is hard to tell what the actual system\r\n% response is.\r\n\r\n%%\r\n% \r\n% <<XYGraphPlot1.png>>\r\n% \r\n%%\r\n% \r\n% <<XYGraphPlot2.png>>\r\n% \r\n%%\r\n% \r\n% <<XYGraphPlot3.png>>\r\n% \r\n\r\n%%\r\n% In the past, to overcome this, you would need to log the data and then\r\n% post-process it in MATLAB to generate the 3D plot.  To address this\r\n% limitation, Giampiero has created a custom 3DScope block that extends the\r\n% X-Y Graph block to three dimensions.  This allows you to visualize the\r\n% interaction of three signals while the simulation is running.\r\n%\r\n% Consider the previous model reconfigured to replace the three X-Y Graph\r\n% blocks with Giampiero's 3DScope block:\r\n%\r\n%%\r\n% \r\n% <<3DScopeModel.png>>\r\n% \r\n% <<3DScopePlot.png>>\r\n% \r\n\r\n%%\r\n% As you can see, this three dimensional plot provides much greater insight\r\n% into the behavior of the system.\r\n%\r\n% To control how the plot looks, there are a number of parameters the user\r\n% can set:\r\n%%\r\n% \r\n% <<3DScopeDialog.png>>\r\n% \r\n%%\r\n% These allow you to specify not only the limits on the axes but also the\r\n% viewpoint for the plot as well as the line style and whether to include\r\n% line markers and a grid.  Giampiero's block is not just limited to a\r\n% single set of three signals as shown previously but by specifying the\r\n% \"Number of point (lines)\" parameter, multiple sets can be plotted as\r\n% shown below:\r\n%%\r\n% \r\n% <<MultipleSignalSetsModel.png>>\r\n%\r\n% <<MultipleSignalSetsPlot.png>>\r\n% \r\n%% Enhancements\r\n%\r\n% There are a number of enhancements that i would like to see Giampiero\r\n% make to this block:  \r\n%%\r\n% \r\n% * Make the figure active so the user can change the viewpoint.\r\n% * Allow the user to specify a line marker for the current location. This\r\n% would help the user to see the current data point and provide a moving\r\n% reference.\r\n% * Allow the user to specify the number of time steps to plot (vs. all\r\n% time steps).  This would reduce the clutter for long simulations. \r\n% \r\n% These enhancements would make the 3DScope block function similarly to the\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/comet3.html comet3> plot in MATLAB.\r\n\r\n%% Comments\r\n% \r\n% Giampiero's 3DScope block provides an additional visualization tool to\r\n% aid in understanding the behavior of your system. Give it a try and let\r\n% us know what you think <https:\/\/blogs.mathworks.com\/pick\/?p=8469#respond\r\n% here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/4915-3dscope#comments\r\n% comment> for Giampiero.\r\n%\r\n \r\n\r\n##### SOURCE END ##### de7ef255ecec4ce18eb4c97b84997cb5\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Richard\/main_3DScope\/XYGraphModel.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\nRichard is a Consulting Engineer at MathWorks focused on the Embedded Coder product for code generation, primarily in the Aerospace industry.Richard&#8217;s pick this week is 3DScope by Giampiero&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2017\/03\/10\/3d-scope\/\">read more >><\/a><\/p>","protected":false},"author":131,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8469"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/131"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=8469"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8469\/revisions"}],"predecessor-version":[{"id":8472,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8469\/revisions\/8472"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=8469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=8469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=8469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}