Can I put an anonymous function into a Simulink block
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Simulink Coder dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!