{"id":118,"date":"2010-12-21T15:50:38","date_gmt":"2010-12-21T15:50:38","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/2010\/12\/21\/kalman-filter-from-matlab-to-embedded-c-code\/"},"modified":"2017-01-02T15:26:28","modified_gmt":"2017-01-02T20:26:28","slug":"kalman-filter-from-matlab-to-embedded-c-code","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2010\/12\/21\/kalman-filter-from-matlab-to-embedded-c-code\/","title":{"rendered":"Kalman Filter &#8211; From MATLAB to Embedded C Code"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/guy_rouleau_small.png\" alt=\"Blogger, Guy Rouleau\" style=\"float: left; margin-right: 1em;\">By <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/31651\">Guy Rouleau<\/a><br><br>\r\n\r\n\r\nIn a previous post, I introduced the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/simulink\/slref\/embeddedmatlabfunction.html\">Embedded MATLAB Function block<\/a>. This block gives the possibility to write an algorithm in MATLAB code, include it in a Simulink model, and generate embedded C code using Real-Time Workshop.<\/p>\r\n\r\n<p>When seeing this, some users, especially from the signal processing and communication domain asked: Do I really need Simulink to generate embedded C code from a MATLAB function?<\/p>\r\n\r\n<p>To answer this question, I would like to highlight a webinar and a submission on the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/\">MATLAB Central File Exchange<\/a> from my colleague <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/22318\">Houman Zarrinkoub<\/a>:<\/p>\r\n\r\n<p><strong>Webinar:<\/strong> MATLAB to C Code Generation with Embedded MATLAB<\/p>\r\n\r\n<p><strong>File Exchange Submission:<\/strong> <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/26862-kalman-filtering-demo-in-matlab-with-automatic-matlab-to-c-code-generation\">Kalman filtering demo in MATLAB with automatic MATLAB-to-C code generation<\/a><\/p>\r\n\r\n<p>Using Embedded MATLAB, you can generate C-code and test your algorithm on the real hardware with only a few clicks. It significantly reduces the turnaround time of design iterations. <\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2010Q4\/DesignIteration.png\" alt=\"Design process using Embedded MATLAB\" \/><\/p>\r\n\r\n<p>For the Kalman filter in Houman's submission, the equations are implemented in MATLAB as you would see them in a book:<\/p>\r\n\r\n <p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2010Q4\/KalmanMATLAB.png\" alt=\"Kalman filter equations\" \/><\/p>\r\n\r\n<p> Then using <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/rtw\/ref\/emlc.html\">emlc<\/a>, the algorithm is converted to C code. For example, the last line of the above code is turned into:<\/p>\r\n\r\n<p> <img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2010Q4\/KalmanEML.png\" alt=\"Kalman filter implemented in C\" \/><\/p>\r\n\r\n<p>So now I recommend that you get yourself a drink, sit down and watch Houman's webinar!<\/p>\r\n\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\n<p>Are you already using Embedded MATLAB to convert your MATLAB code into C-code? Leave a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=118&amp;#comment\">comment here<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>By Guy Rouleau\r\n\r\n\r\nIn a previous post, I introduced the Embedded MATLAB Function block. This block gives the possibility to write an algorithm in MATLAB code, include it in a Simulink model, and... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2010\/12\/21\/kalman-filter-from-matlab-to-embedded-c-code\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,102,24,30],"tags":[168,169,457,441],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/118"}],"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=118"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":6166,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/118\/revisions\/6166"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}