|
"Steven Lord" <slord@mathworks.com> wrote in message
news:hesfdj$htb$1@fred.mathworks.com...
>
> "Shota " <shotaemail@gmail.com> wrote in message
> news:hek7ms$fpa$1@fred.mathworks.com...
>> There is a block in the library called "MATLAB Fcn".
>>
>> I have my own function written in matlab, and its output called
>> "my_output" is a structure.
>>
>> "MATLAB Fcn" block in Simulink can NOT be used for my function because
>> its output is a structure.
>>
>> I know I could change my matlab function and have the output "my_output"
>> as an array, and "MATLAB Fcn" can be used.
>>
>> But let's suppose I DO NOT want to change "my_output" to an array for a
>> reason. But I still want to run my matlab function run in my simulink.
>>
>> I know I can run my matlab function as a subsytem's initialization. But I
>> need to run my matlab function multiple times during a simulation run.
>>
>> I'd appreciate your time and help greatly.
>
> Write another small function that accepts the inputs from the MATLAB Fcn
> block, calls the function that returns a struct, and returns the
> appropriate piece of that structure (as required by the block.)
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ:
> http://matlabwiki.mathworks.com/MATLAB_FAQ
You might also want to use an Embedded MATLAB block rather than a MATLAB Fcn
block. The MATLAB Fcn block calls the MATLAB engine at each time step, and
is very slow and inefficient. Embedded MATLAB uses C code generation and is
a lot faster and more efficient. I am not sure whether structures are
supported though. I would question the need for a having a structure output.
Is it really necessary?
Arnaud
|