Guy and Seth on Simulink
December 21st, 2010
Kalman Filter – From MATLAB to Embedded C Code
By Guy Rouleau
In 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 generate embedded C code using Real-Time Workshop.
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?
To answer this question, I would like to highlight a webinar and a submission on the MATLAB Central File Exchange from my colleague Houman Zarrinkoub:
Webinar: MATLAB to C Code Generation with Embedded MATLAB
File Exchange Submission: Kalman filtering demo in MATLAB with automatic MATLAB-to-C code generation
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.

For the Kalman filter in Houman's submission, the equations are implemented in MATLAB as you would see them in a book:

Then using emlc, the algorithm is converted to C code. For example, the last line of the above code is turned into:

So now I recommend that you get yourself a drink, sit down and watch Houman's webinar!
Now it's your turn
Are you already using Embedded MATLAB to convert your MATLAB code into C-code? Leave a comment here
By
Guy Rouleau
15:50 UTC |
Posted in Code Generation, MATLAB, Model-Based Design, Modeling |
Permalink |
7 Comments »
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
Leave a Reply
|
i am new to matlab, i find that the recoreded webinar in your web is very useful. iwant to know how can i download them.
Good Job !
Hi, Guys.. I’m indonesian student,, I looking for Ensemble Kalman Filter Program.. Any one help me!
1) you should improve blog so I can thumbs-up others comments instead of saying again (I have not done this before, it looks interesting. good job!). :)
2) being able to perform the same work demonstrated in the webinar using CUDA would be interesting. The makers of “Jacket” like to show (using poor benchmarking) that CUDA is 100x faster than CPU. Typical (published) realistic improvements are 6x to 16x faster.
3) I would love to learn more about optimizing high-level code for embedded devices.
Hi, I really need help urgently, I made the image processing with matlab, and would now like to implement in some fpga or dsp by HDL or C code
hope I can help, congratulations and I hope your answer, THANKS!
hi teacher ,how are you? I hope you are fine.I am a physics engineering student. I want to ask a question.how can I do measurement of gravity with simple pendulum in matlab programme? thank you:)))
Can u explain the steps that involved in converting the .m file to .c file?