Implementing your own function in a simulink model
Show older comments
I have written a simple color filter function in MATLAB 2010a. I am trying to create a Simulink model where I can pass live video through this function so that I can see only the color blue, however I never seem to find the right block for user defined functions. I have tried the Embedded MATLAB function, but it never seems to work and I don't think it is for what I am trying to do. I have tried the function block, but that only takes a one dimensional input, video has three. The other option is s-functions, but I don't know if that is too complicated for what I am trying to do. I would appreciate it if someone could point me in the right direction.
Thanks,
Roshan
Accepted Answer
More Answers (1)
Guy Rouleau
on 3 Mar 2011
1 vote
I wrote the following post especially to give tips on finding the best implementation for your for problems like yours:
Based on the description you give, I would go for a level 2 MATLAB s-function. It is not as complicated as it seems and give you all the power of MATLAB. If you plan to generate code for deployment on a real-time system, then I recommend Embedded MATLAB.
2 Comments
Roshan
on 7 Mar 2011
Guy Rouleau
on 8 Mar 2011
"@" is to define a function handle, do a quick doc search for "function handle" to learn more on that topic. Note that you don't really need it here. Type "sfundemos" in MATLAB to open all the s-function demos. Then look in the MATLAB files ection and the Level 2. You will find many examples and the template. I recommend always starting form a demo or the template to make you blocks.
To answer "what does block.NumDialogPrms mean?", please use the doc or try your intuition... Num as in "Number", dialog as in "dialog" and "Prms" s in parameters... assemble that and you have a parameter defining the number of dialog parameters of your block ;-)
http://www.mathworks.com/help/toolbox/simulink/slref/simulink.runtimeblock.html
HTH,
Guy
Categories
Find more on Block and Blockset Authoring in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!