datatypes supported by simulink

1 次查看(过去 30 天)
Ahmed Tawfeeq
Ahmed Tawfeeq 2012-2-14
编辑: Mathias 2013-10-13
Hi everybody...I am a few steps away from fulfilling my design concerning calling functions to matlab function block....but I stumbled in defining the datatypes of the function adaptfilt.lms I don't know how to define this function beacause when using class(h) where h=adaptfilt.lms, the answer is :adaptfilt.lms which is completely invalid if anyone know that simulink does not support such function type please tell my to stop my pointless trials and turn to another way..thanks alot.
  2 个评论
Kaustubha Govind
Kaustubha Govind 2012-2-14
Ahmed: This question seems similar to the one already answered at http://www.mathworks.com/matlabcentral/answers/28745-matlab-simulink-supported-data-types - perhaps you should provide a snippet of your code or explain your question better if the previous answer didn't help you.
Ahmed Tawfeeq
Ahmed Tawfeeq 2012-2-15
Hi Kaustubha....I will explain my work,it is a part of my MSc thesis..honestly it's not a design..it's just turning the ecg matlab code in help (DSP System Toolbox/Demos/Adaptive Processing/ANC Applied to Fetal Electrocardiography)to simulink block!...the problematic code is:
h = adaptfilt.lms(15,0.00007);
[y,e] = filter(h,x,d);
..I could call all matlab codes to simulink block (creating maternal ecg..)but I stopped at (Applying Adaptive Noise Canceller) in adaptfilt.lms when I used code.extirinsic(adaptfilt.lms) , it showed an error message saying:[(Function 'adaptfilt' implicitly resolved in the MATLAB workspace. Implicit evaluation in MATLAB is not supported. Please declare this function extrinsic using coder.extrinsic('adaptfilt'), or call it using feval.)] as though it did not understand it as extrinsic......I tried to call only adaptfilt but there was an error saying:y cannot be of matlab type(y=function output)[problem of how to define the datatype of adaptfilt.lms becasue the default "double" does not match]
I tried to call them seperately ...but how to combine them?(dot problem)error message:[[Dot notation on function call return value is not allowed]].
Then I tried to follow your advice ...I used [which adaptfilt.lms]
then I copied lms.m into a seperate matlab function block ...then I fed the output of this block (equivalent to adaptfilt.lms)as input to another block,which called the "filter"function , such that , getting rid of the problem of the dot notation, but there was also an error saying:varargin cannot be used as a top level function.I don't know what to do.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2012-2-14
Stop your pointless trials and turn to another way. ;-)
You will not be able to pass objects of arbitrary classes as parameters in Simulink, as best I can tell. The problem is not the dot; the problem is that the class is not one of the ones already defined for Simulink to be able to pass around.
You should consider whether it is really necessary to pass the entire adaptive filter object around. Is it not enough in your situation to construct it and use it all inside the MATLAB Function Block? If the adaptive filter is needed in several places, is it important that it be the same adaptive filter object each time, or would it be permitted to pass the construction parameters around and build it each time it was needed?
If it is important that it be the same filter object each time, then consider defining it in a MATLAB function and using "persistent" to hold on to its value in that function; then when the other locations need it, they could call the same routine with parameters indicating that they want to retrieve the object.
If you need several different adaptive filter objects simultaneously then you could use a variation of the above except that the routine returns an "id" (which could be as simple as an index in to an array) and the retrieving routine passes in the ID to indicate which particular object it needs to retrieve.

类别

Help CenterFile Exchange 中查找有关 Filter Implementation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by