There are 3 ways to use Matlab functions in simulink.
- Interpreted Matlab functions
- level 1 Matlab s-functions
- level 2 Matlab s-functions
Personally I neither like level 1 s-functions nor interpreted Matlab functions. For level 1 s-functions you gotta tell simulink which functions you plan to use, similar to an include.
Interpreted Matlab functions are pretty restricted so I'd suggest you a level 2 Matlab s-function, as soon as you intend to do a little advanced stuff.
Also I'd suggest you to use 3 dimensional arrays instead of structs, a picture is a x*y*3 array which you can use in a simulink-block. You can use setInputDimension to get the input-size and set the output size according to your wishes (level 2 s-function).
Also if your problems is just the format struct you can write a simple script which transforms the struct into a three dimensional array, wich is no issue for simulink (in this case you can go with the interpreted matlab function).
At last: I am pretty sure you can't use structs to pass data between simulink blocks, except you read and write to the base workspace, and infact pass no real information between your blocks.
I hope that helped a little.