%%% this script developed by kls, 2/16/2021
%%% to run, open Matlab, click new->script, and copy-and-paste this text
clc
clear all
close all
%It is good practice to begin every code with these three lines - they
%clear and close any variables and figures that may still exist from a
%previous program.
%%% Defining Variables %%%
A = 3;
% A is a real value
B = j*4;
% B is an imaginary value
C = 0:0.1:1;
% C is a 1x11 vector containing values from 0 to 1, in steps of 0.1
D = A + B;
%D is a complex value ( equivalently, you could write D = 3+j*4; )
magD = abs(D);
angleD = angle(D); %by default, this is in radians
angleDdeg = angleD*180/pi %this converts it to degrees.
sprintf('The value of D is %f at an angle of %f degrees',magD,angleDdeg)