Effacer les filtres
Effacer les filtres

How to link my custom MATLAB function into my Simulink model?

12 vues (au cours des 30 derniers jours)
Mark Golberg
Mark Golberg le 13 Fév 2021
Hello,
I have my custom matab function:
function [statusMessage , Files_TF] = doAllFilesExist_v2(dataPath , handles)
I'd like to add it to my simulink model, via some reference/link block or something like that.
I thought I could use MATLAB function block, but it's only for creating NEW functions. I do NOT want to re-create my function AGAIN.
Is there some way for me to create a "MATLAB (custom-existing-not-new) block" ?
THANKS !!!

Réponse acceptée

Walter Roberson
Walter Roberson le 14 Fév 2021
No, there is not.
If it were a Level 2 S function (which we can see from the header it is not), then you would use https://www.mathworks.com/help/simulink/slref/level2matlabsfunction.html
If it were a Level 1 S function (which we can see from the header it is not), then you would use https://www.mathworks.com/help/simulink/slref/sfunction.html
However, what you have is a MATLAB Function, which needs to be incorporated through a MATLAB Function Block. In Simulink, MATLAB functions do not just float around as pure calls to MATLAB functions: they have to exist as blocks that have properties such as location and ports and signal attributes. And, unfortunately, MATLAB Function Blocks do not permit the source to be incoporated by reading it in from a file.
So... what you end up needing to do is create a MATLAB Function Block that doesn't do much except call your function.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Environment Customization dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by