How do I pass a Complex input to a MATLAB file S-function?

I have an MATLAB file S-function and I want it to handle complex inputs.

 Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 1 de Jul. de 2009
MATLAB file S-functions cannot handle complex inputs, unlike C-Mex S-functions. However, the following workaround can be used to have MATLAB file S-functions work with complex inputs.
1. Use the Complex to Real-Imaginary block from the Simulink Math library to split the complex signal into two parts.
2. Use a Mux block from the Signals & Systems library to combine these two parts into a two element vector.
3. Pass this vector as input to the MATLAB file S function.
4. Make sure inside the MATLAB file S function the number of inputs is set to 2
sizes.NumInputs = 2;
An example that demonstrates how complex input can be handled is attached at the bottom of the page.
In the example, the conjugate of a complex number is calculated using a MATLAB file S-function.

Más respuestas (0)

Categorías

Más información sobre Block and Blockset Authoring en Centro de ayuda y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by