MATLAB: Implementing your own function in a simulink model

color filtercolor filter simulinkimage processingsimulinkuser defined functions

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

Best Answer

Look at examples like the penddemo, inside the animation subsystem (look under mask) there's one s-function block that interacts with the simulation, the code for it is implemented on just one m file (s-function parameters), maybe you can do the same.