summaryrefslogtreecommitdiff
path: root/matlab/phasor.m
diff options
context:
space:
mode:
Diffstat (limited to 'matlab/phasor.m')
-rw-r--r--matlab/phasor.m15
1 files changed, 15 insertions, 0 deletions
diff --git a/matlab/phasor.m b/matlab/phasor.m
new file mode 100644
index 0000000..add5f84
--- /dev/null
+++ b/matlab/phasor.m
@@ -0,0 +1,15 @@
+function phasor(modulus, argument)
+ % Wrapper for quiver() that plots phasor diagrams.
+ %
+ % Expects the modulus and argument (in degrees)
+ % of a complex number.
+
+ r = modulus;
+ phi = argument * pi / 180;
+
+ % Automatic scaling is disabled.
+ quiver(0, 0, r*cos(phi), r*sin(phi), 0);
+
+ xlim([-r r]);
+ ylim([-r r]);
+end \ No newline at end of file