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

Version 1.0.0.0 (1,18 KB) von Peter Mao
A wrapper function to allow use of complex numbers in functions of the form F(X,Y,...).
219 Downloads
Aktualisiert 6. Jun 2013

Lizenz anzeigen

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.

Zitieren als

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

Kompatibilität der MATLAB-Version
Erstellt mit R2013a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Scatter Plots finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0.0