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.

 채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 7월 1일

0 개 추천

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.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Block and Blockset Authoring에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by