{"id":163,"date":"2011-11-28T20:00:33","date_gmt":"2011-11-28T20:00:33","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/2011\/11\/28\/finding-where-variables-are-used-from-the-model-explorer\/"},"modified":"2011-11-20T10:44:34","modified_gmt":"2011-11-20T10:44:34","slug":"finding-where-variables-are-used-from-the-model-explorer","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2011\/11\/28\/finding-where-variables-are-used-from-the-model-explorer\/","title":{"rendered":"Finding where variables are used from the Model Explorer"},"content":{"rendered":"<p>In a <a href=\"https:\/\/blogs.mathworks.com\/seth\/2010\/04\/22\/variables-you-depend-on\/\">previous post<\/a>, we illustrated the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011b\/toolbox\/simulink\/slref\/simulink.findvars.html\"><tt>Simulink.findVars<\/tt><\/a> function.<\/p>\r\n\r\n<p>To be honest, I am not very good at remembering the syntax of functions. Every time I encounter a situation where I could use <tt>Simulink.findVars<\/tt>, I need to open the documentation to figure out how to use it. Being a Simulink user, if there is a way I can click somewhere to get or set what I want, you can be sure I will go that way.<\/p>\r\n\r\n<p>For those like me, I want to share this trick I just discovered.<\/p>\r\n\r\n<p><strong>Find Where Used<\/strong><\/p>\r\n\r\n<p>Most models rely on tens or even hundreds of variables in the workspace.  Sometimes I need to know which blocks in the model use a specific variable. To accomplish this, open the model and right click on the variable. You will see a <strong>Find Where Used<\/strong> option:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q3\/findVars_ModelExplorer.png\" alt=\"Finding variables form the Model Explorer\"><\/p>\r\n\r\n<p>This will launch a window asking if you want to search for a specific model or all open models:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q3\/findvars_selectModel.png\" alt=\"Selecting the search scope\"><\/p>\r\n\r\n<p>Depending on the type of variable, the search might require a model update. Once this is done, you will get the list of blocks using the variable.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q3\/foundBlocks.png\" alt=\"Found blocks\"><\/p>\r\n\r\n<p>Double click on the block name. Simulink will bring it up and highlight it:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q3\/foundBlockInModel.png\" alt=\"Found block highlighted\"><\/p>\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\nLook at the documentation section titled <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011b\/toolbox\/simulink\/ug\/bso5b65.html\">The Model Explorer: Working with Workspace Variables<\/a> and let us know how this is applicable to your work-flow. Leave us a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=163&amp;#comment\">comment here<\/a>.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>In a previous post, we illustrated the Simulink.findVars function.\r\n\r\nTo be honest, I am not very good at remembering the syntax of functions. Every time I encounter a situation where I could use... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2011\/11\/28\/finding-where-variables-are-used-from-the-model-explorer\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[24,69,33],"tags":[131,154],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/163"}],"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=163"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/163\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}