

{"id":1199,"date":"2013-11-27T11:58:52","date_gmt":"2013-11-27T10:58:52","guid":{"rendered":"https:\/\/project.inria.fr\/plasma-lab\/?page_id=1199"},"modified":"2015-03-13T11:43:51","modified_gmt":"2015-03-13T10:43:51","slug":"matlabsimulink","status":"publish","type":"page","link":"https:\/\/project.inria.fr\/plasma-lab\/documentation\/tutorial\/matlabsimulink\/","title":{"rendered":"MATLAB\/Simulink"},"content":{"rendered":"<p><\/p>\n<p style=\"text-align: justify;\">We integrated PLASMA Lab and MATLAB\/Simulink. The idea of this integration is to let MATLAB\/Simulink run a model and produce sample traces. These samples are then be sent to PLASMA Lab in order to check them. See the <a href=\"https:\/\/project.inria.fr\/plasma-lab\/plasma-structure\/\"><strong>PLASMA Lab architecture explanation<\/strong><\/a> to understand how this is possible.<\/p>\n<p>We provide two different ways of using this feature:<\/p>\n<ul>\n<li>Use PLASMA Lab SMC algorithms from within MATLAB<\/li>\n<li>Launch a MATLAB session from the PLASMA Lab user interface<\/li>\n<\/ul>\n<hr \/>\n<h3>From MATLAB\/Simulink<\/h3>\n<p>This MatLab App allows you to choose a Simulink model and test a B-LTL property on it using on of our three SMC algorithms (Monte Carlo, Chernoff and Sequential).<\/p>\n<div id=\"attachment_1223\" style=\"width: 266px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/project.inria.fr\/plasma-lab\/files\/2013\/11\/plasma2simulink_screenshot.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1223\" class=\"size-medium wp-image-1223 \" title=\"PLASMA2Simulink App\" alt=\"plasma2simulink_screenshot\" src=\"https:\/\/project.inria.fr\/plasma-lab\/files\/2013\/11\/plasma2simulink_screenshot-256x300.png\" width=\"256\" height=\"300\" srcset=\"https:\/\/project.inria.fr\/plasma-lab\/files\/2013\/11\/plasma2simulink_screenshot-256x300.png 256w, https:\/\/project.inria.fr\/plasma-lab\/files\/2013\/11\/plasma2simulink_screenshot.png 628w\" sizes=\"auto, (max-width: 256px) 100vw, 256px\" \/><\/a><p id=\"caption-attachment-1223\" class=\"wp-caption-text\">PLASMA2Simulink MatLab App<\/p><\/div>\n<p>How to install and use this App?<\/p>\n<ol>\n<li>Requirements: This App was tested with MATLAB R2013a and R2013b, under Windows7 and Fedora 19.<\/li>\n<li style=\"text-align: justify;\">Installation: Download PLASMA2Simulink App (latest version is 1.2.20 <a href=\"http:\/\/plasma-lab.gforge.inria.fr\/plasma_lab_bundle\/plasma2simulink\"><strong>accessible here<\/strong><\/a>) and install it in MATLAB (Click on &#8220;Install App&#8221; in the tab &#8220;APPS&#8221;) <strong><strong><\/strong><\/strong>. The installer should add a PLASMA2Simulink icon in the category &#8220;My APPS&#8221;.<br \/>\n<a href=\"https:\/\/project.inria.fr\/plasma-lab\/files\/2013\/11\/PLASMA2Simulink_24.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1224\" alt=\"PLASMA2Simulink_24\" src=\"https:\/\/project.inria.fr\/plasma-lab\/files\/2013\/11\/PLASMA2Simulink_24.png\" width=\"24\" height=\"24\" \/><\/a><\/li>\n<li>Launch the App.<\/li>\n<li>Choose a Simulink model, write your <a href=\"https:\/\/project.inria.fr\/plasma-lab\/Property%20Language\/\"><strong>B-LTL<\/strong><\/a> requirement and choose your algorithm.<br \/>\nAlgorithm parameters are separated by spaces and are given following the order as in the <a href=\"https:\/\/project.inria.fr\/plasma-lab\/check-a-property\/\"><strong>PLASMA Lab tutorial<\/strong><\/a>.<\/li>\n<li>You are now set up, click on the &#8220;Go !&#8221; button to launch the experiment.<\/li>\n<\/ol>\n<p>See <strong>How does it work ?<\/strong> below for further details.<\/p>\n<hr \/>\n<h3>From PLASMA Lab<\/h3>\n<p>Since PLASMA Lab v1.2.6, you can download the MATLAB\/Simulink PLASMA Lab plugin and run it from PLASMA Lab. This plugin will allow you to:<\/p>\n<ul>\n<li>Run a Simulink model from within PLASMA Lab<\/li>\n<li>Check a property on this model<\/li>\n<\/ul>\n<div id=\"attachment_1205\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/project.inria.fr\/plasma-lab\/files\/2013\/11\/tutoPlasmaMatlab.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1205\" class=\"size-medium wp-image-1205 \" alt=\"tutoPlasmaMatlab\" src=\"https:\/\/project.inria.fr\/plasma-lab\/files\/2013\/11\/tutoPlasmaMatlab-300x187.png\" width=\"300\" height=\"187\" srcset=\"https:\/\/project.inria.fr\/plasma-lab\/files\/2013\/11\/tutoPlasmaMatlab-300x187.png 300w, https:\/\/project.inria.fr\/plasma-lab\/files\/2013\/11\/tutoPlasmaMatlab-1024x640.png 1024w, https:\/\/project.inria.fr\/plasma-lab\/files\/2013\/11\/tutoPlasmaMatlab.png 1920w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1205\" class=\"wp-caption-text\">PLASMA Lab and MATLAB\/Simuling running together<\/p><\/div>\n<p>How to install and use this plugin? (this was only tested on Linux)<\/p>\n<ol>\n<li>Requirements: PLASMA Lab v1.2.6 or superior, a MATLAB\/Simulink installation accessible from the command line.<\/li>\n<li>Install the MATLAB\/Simulink plugin (<a href=\"https:\/\/project.inria.fr\/plasma-lab\/plugins\/\"><strong>accessible here<\/strong><\/a>) following the instruction <a href=\"https:\/\/project.inria.fr\/plasma-lab\/plugin-tutorial\/#Deployment\"><strong>plugin installation<\/strong><\/a>. Or download <strong>the latest PLASMA Lab bundle already including MATLAB\/Simulink plugin <strong> &#8212; <a href=\"http:\/\/plasma-lab.gforge.inria.fr\/plasma_lab_bundle\/PLASMA_Lab-1.2.6.tar.gz\">[tar.gz]<\/a> &#8212; <a href=\"http:\/\/plasma-lab.gforge.inria.fr\/plasma_lab_bundle\/PLASMA_Lab-1.2.6.zip\">[zip]<\/a><\/strong><\/strong>.<\/li>\n<li>Run PLASMA Lab. If you are running PLASMA Lab from a terminal you should see a line indicating that the MATLAB\/Simulink model has been loaded. You can also see this by checking the information in the Help&gt;About PLASMA Lab menu.<\/li>\n<li>Create a new model for your project, and choose the MATLAB\/Simulink plugin as the type of the model. As the model compile for the first time, MATLAB\/Simulink should launch itself and load the &#8216;F14&#8217; model. It may take some time. Alternatively you can download a PLASMA Lab project file already set <a href=\"http:\/\/plasma-lab.gforge.inria.fr\/plasma_lab_examples\/MatlabSession.plasma\"><strong>here<\/strong><\/a>.<\/li>\n<li>You are now set up and can use PLASMA Lab <a href=\"https:\/\/project.inria.fr\/plasma-lab\/how-to-simulate-a-model\/\"><strong>simulator<\/strong><\/a> or <a href=\"https:\/\/project.inria.fr\/plasma-lab\/check-a-property\/\"><strong>experiment<\/strong><\/a> mode.<\/li>\n<\/ol>\n<hr \/>\n<h3>Configuration of Simulink models and examples<\/h3>\n<p style=\"text-align: justify;\">Any Simulink model can be used by PLASMA Lab. However to provide significant results the models should present true random behaviors. This is not possible using on the shelf Simulink blocks, as random sequences generated in these blocks are always the same at each simulation. We therefore advice to include C code functions using the S-Function builder block.<\/p>\n<p style=\"text-align: justify;\">B-LTL requirement can be written using the standard syntax used by PLASMA Lab. The variables used in these requirements must be variables logged by Simulink. To log a signal apply the following steps:<\/p>\n<ol>\n<li>Select a link in the Simulink model and right click on properties.<\/li>\n<li>Give a name to the signal.<\/li>\n<li>Check the box &#8220;Log signal data&#8221; under the tab &#8220;Logging and accessibility&#8221;<\/li>\n<\/ol>\n<p>We provide two examples that can be used with PLASMA Lab:<\/p>\n<ul>\n<li><a href=\"https:\/\/project.inria.fr\/plasma-lab\/?p=1351\"><strong>Fault-Tolerant Fuel Control System<\/strong><\/a><\/li>\n<li><a href=\"https:\/\/project.inria.fr\/plasma-lab\/temperature-controller-of-a-pig-shed\/\"><strong>Temperature controller of a pig shed<\/strong><\/a><\/li>\n<\/ul>\n<hr \/>\n<h3>How does it work?<\/h3>\n<p style=\"text-align: justify;\">PLASMA Lab itself connect to MATLAB via the MatlabProxy class from the <a href=\"http:\/\/code.google.com\/p\/matlabcontrol\/\"><strong>matlabcontrol project<\/strong><\/a>. The MATLAB\/Simulink session then retrieves the <em>content<\/em> of the PLASMA Lab model panel and uses this String to make call to Matlab.<\/p>\n<p>These calls are equivalent to the following MATLAB code:<\/p>\n<ul>\n<li>open_system(&#8216;<em>content<\/em>&#8216;)<\/li>\n<li>[timeVector,stateVector,outputVector] = sim(&#8216;&#8221;+<em>content<\/em>+&#8221;&#8216;);<\/li>\n<\/ul>\n<p>In order to open and execute a Simulink model, replace <em>content<\/em> by the text (model name or path) you would use in MATLAB.<\/p>\n<p><strong>Retrieving the execution trace:<\/strong> for now, we retrieve the model execution trace as an 2D array, each column representing a variable and its values for each step. <strong>Each variables are given name<\/strong> using their <strong>column index to identify them<\/strong> starting from 1.<em> ie: to identify the first column, use the variable name v_1.<\/em><\/p>\n<p>Execute<em> [timeVector,stateVector,outputVector] = sim(modelName)<\/em> in MATLAB to see the <em>stateVector<\/em> used by PLASMA Lab.<\/p>\n<div class=\"alert alert-warning\" role=\"alert\"><p class=\"printonly\"><strong>Warning!<\/strong><\/p>\n<h3>FAQ<\/h3>\n<p class=\"first-p\">Opening or creating a new MATLAB Session model throw an error in MATLAB. <em>This error is related to MatLabControl, the library used to interface PLASMA Lab and MATLAB. http:\/\/code.google.com\/p\/matlabcontrol\/issues\/detail?id=12 It means that if you restart PLASMA Lab you will not be able to use the same MATLAB Session, a new one will be created.<br \/>\n<\/em><\/p>\n<p>Java WebStart: <em>The MATLAB\/Simulink plugin is not available from our PLASMA Lab WebStart distribution since JavaWS forbid to run external application from it. Be sure to choose the Download method to use it.<br \/>\n<\/em><\/p>\n<p><\/div><\/p>","protected":false},"excerpt":{"rendered":"<p>We integrated PLASMA Lab and MATLAB\/Simulink. The idea of this integration is to let MATLAB\/Simulink run a model and produce sample traces. These samples are then be sent to PLASMA Lab in order to check them. See the PLASMA Lab architecture explanation to understand how this is possible. We provide\u2026<\/p>\n<p> <a class=\"continue-reading-link\" href=\"https:\/\/project.inria.fr\/plasma-lab\/documentation\/tutorial\/matlabsimulink\/\"><span>Continue reading<\/span><i class=\"crycon-right-dir\"><\/i><\/a> <\/p>\n","protected":false},"author":234,"featured_media":0,"parent":135,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-1199","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/project.inria.fr\/plasma-lab\/wp-json\/wp\/v2\/pages\/1199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/project.inria.fr\/plasma-lab\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/project.inria.fr\/plasma-lab\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/project.inria.fr\/plasma-lab\/wp-json\/wp\/v2\/users\/234"}],"replies":[{"embeddable":true,"href":"https:\/\/project.inria.fr\/plasma-lab\/wp-json\/wp\/v2\/comments?post=1199"}],"version-history":[{"count":20,"href":"https:\/\/project.inria.fr\/plasma-lab\/wp-json\/wp\/v2\/pages\/1199\/revisions"}],"predecessor-version":[{"id":1624,"href":"https:\/\/project.inria.fr\/plasma-lab\/wp-json\/wp\/v2\/pages\/1199\/revisions\/1624"}],"up":[{"embeddable":true,"href":"https:\/\/project.inria.fr\/plasma-lab\/wp-json\/wp\/v2\/pages\/135"}],"wp:attachment":[{"href":"https:\/\/project.inria.fr\/plasma-lab\/wp-json\/wp\/v2\/media?parent=1199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}