Although pretty good with Matlab, I’m a total amateur with Simulink so hoping someone can help.
I have a Matlab function y = fun1(x,M) that I want to put into a Simulink block (and later create an S-function version). x will come from another block in the Simulink model. M is a structure with a lot of information; it doesn’t change and I want to embed it in the Simulink block. I don’t want the block to have to load M from a matfile or call additional functions each time.
So, I thought to create an anonymous function as follows: anon_fun = @(x)fun1(x,M);
And then put the anon_fun in a Matlab Function, fcn or similar Simulink block. But none of these seem to work!
Is it possible to embed an anonymous function in a Simulink block, which type, and will I be able to generate an S-function from it?
Thanks in advance for any tips.
Best Answer