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.

 Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 1 Jul. 2009

0 Stimmen

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.

Weitere Antworten (0)

Kategorien

Mehr zu Block and Blockset Authoring finden Sie in Hilfe-Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by