From: Edmund on
Hi,

Is there a way to transfer variables used in simulink function to a level 2 Mfile s-function in simulink model?

I am generating a value of a variabel r by using fcn block, how can I associate that variable in a code I have written in Matlab .m file in which I am allocating in the level 2 Mfile s-function. When ever I am righting r in the .m file it is saying "Undefined function or variable 'r'" even though I am connection the output of fcn block with the input of the 2 Mfile s-function block.

Thanks.
Edmund
From: dk on
On Mar 24, 4:13 am, "Edmund " <azuro20...(a)hotmail.com> wrote:
> Hi,
>
> Is there a way to transfer variables used insimulinkfunction to a level 2 Mfile s-function insimulinkmodel?
>
> I am generating a value of a variabel r by using fcn block, how can I associate that variable in a code I have written in Matlab .m file in which I am allocating in the level 2 Mfile s-function. When ever I am righting r in the .m file it is saying "Undefined function or variable 'r'" even though I am connection the output of fcn block with the input of the 2 Mfile s-function block.
>
> Thanks.
> Edmund

Once you have done connecting the outport of a function block to
inport of S-Function block, you will have to read the corresponding
inport inside the S function to get the value of 'r'.