summaryrefslogtreecommitdiff
path: root/matlab/phasor.m
diff options
context:
space:
mode:
authorWarrick Lo <warrick.s.z.lo@gmail.com>2026-02-11 07:16:45 -0800
committerWarrick Lo <warrick.s.z.lo@gmail.com>2026-02-11 07:16:45 -0800
commitf1a9a85c6138715c3933c957c695d0482b901154 (patch)
treef2d6ca37aa60eb35737f31a4a8ab3a202e07f01c /matlab/phasor.m
Finish lab report up to Task 2B
Signed-off-by: Warrick Lo <warrick.s.z.lo@gmail.com>
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