Phasor diagrams in GNU Octave

I’ve been experimenting with plotting phasor diagrams in GNU Octave. This approach may also work in MATLAB, but I haven’t tried that yet. I need to tidy this up a little more to make it convenient to reuse, but I’m capturing it as it is for the time being, so that I don’t lose it. This is my M-file, “example.m”:

%
% GNU Octave phasor plot example
% Written by Ted Burke - 19-2-2014
%

% Create a few complex values
z1 = 3 + 3j;
z2 = 2 + 4j;
z3 = z1 * z2;

% Calculate a suitable axis limit based on phasors
m = 1.2 * max([real([z1 z2 z3]) imag([z1 z2 z3])]);

% Create a new figure window
figure
hold on

% Plot phasors one at a time
quiver(0,0,real(z1),imag(z1))
quiver(0,0,real(z2),imag(z2))
quiver(0,0,real(z3),imag(z3))

% Add horizontal and vertical axes
plot([-m m],[0 0])
plot([0 0],[-m m])

% Set axis limits and aspect ratio
axis([-m,m,-m,m], 'square')

To install octave in Linux (debian), just run the following command as root:

apt-get install octave

Then, to run the example: 