calling a standalone function to matlab function block

hi....I wonder if anyone has an idea about how to call a standalone function (like filter function or any function else which is in fact a subroutine)to matlab function block because my research needs such process....and whether matlab supports that or not? please help...thanks in advance.

 Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 27 Jan 2012

1 vote

You can use any of functions supported for code-generation inside a MATLAB Function block. However, if you do not plan to generate embedded C/C++ code from your Simulink model, you can declare unsupported functions using coder.extrinsic and use them in the block.

5 commentaires

I have already used coder.extrinsic but unfortunately , simulink showed an errors first of them says "output y cannot be of matlab type " and others errors say"Errors occurred during parsing of MATLAB function 'MATLAB Function'(#70) " a coder and interface error succesively...if you have any hints about that, please inform me....thank you for your time.
That error is addressed in the documentation: http://www.mathworks.com/help/toolbox/eml/ug/bq1h2z9-38.html#bq1h2z9-46
You need to pre-allocate the variables that represent the outputs of the functions that you are calling using coder.extrinsic.
Hi....I think I have managed to call the standalone function (ecg function) to matlab function block , but now , I can't show the matrix result because an only block error says"The signal at input port 1 of 'boleh/Scope' is a variable-size signal with a nondiscrete sample time. The sample time for any variable-size signal must be discrete." , I can't find a way to modify the sample time of the block output.???
There might be downstream blocks that are specifying a continuous sample time - Simulink back-propagates that to the MATLAB Function block. I can't think of a way that you can use to directly specify the sample-time of the block.
Hi Kaustubha...I would like to thank you for your help... thankfully I could solve all problems I encountered concerning calling functions to simulink, but i stopped at the function adaptfilt.lms ...i don't know what (.)represent....thanks again.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by