Call 2D real functions with complex numbers (cmplx.m)

A wrapper function to allow use of complex numbers in functions of the form F(X,Y,...).

Al momento, stai seguendo questo contributo

I frequently store X,Y vector data as a single complex vector V = X + iY. This makes for easy translation, rotation and scaling manipulation. Distances between data points and dot and cross products are also easy in the complex plane.

For functions that require the form F(X,Y,...), such as SCATTER, I get tired of typing:
SCATTER(REAL(V), IMAG(V), SIZE, COLOR);
With this function, SCATTER would be called like this:
CMPLX(@SCATTER, V, SIZE, COLOR);

The advantage of this method is clearer when you start to put cuts into your data. For example, here if I change the cut variable, then I only have to alter it in one place:

CUT1 = FIND(ABS(V) > 3.5);
CMPLX(@SCATTER, V(CUT1), SIZE, COLOR);

This function does not alter the shape of your inputs. If the function requires column vectors, then use "(:)" on V:

CMPLX(@F, V(:), ...);

This is a stupidly short function, but I hope you find it useful.

Cita come

Peter Mao (2026). Call 2D real functions with complex numbers (cmplx.m) (https://it.mathworks.com/matlabcentral/fileexchange/42123-call-2d-real-functions-with-complex-numbers-cmplx-m), MATLAB Central File Exchange. Recuperato .

Informazioni generali

Compatibilità della release di MATLAB

  • Compatibile con qualsiasi release

Compatibilità della piattaforma

  • Windows
  • macOS
  • Linux
Versione Pubblicato Note della release Action
1.0.0.0