% DEMO:         VERIFYING EULER'S IDENTITY
%
% Program:      cn_eulers_id.m
% Written by:   
% For:          EE 311
%               Extra Demo for Computer Lab 1
% Date:         6-6-2001
% Purpose:      This program uses Euler's Identity to
%               compute the real and imaginary parts of
%               the complex number z=r*exp(theta)
%               In essence, this program uses Euler's Id
%               to convert polar complex numbers to 
%               Cartesian complex numbers
clear all, clc
j=sqrt(-1);
disp('Enter a complex number in polar form (i.e. z=r*exp(j*theta)')
r=input('Enter the magnitude of z:        ');
deg=input('Enter the phase of z in degrees: ');
theta=deg*pi/180;        % Convert degrees to radians for MATLAB

disp(' ')
disp(' ')
disp('Euler''s Identity says that:')
disp('exp(j*theta) = cos(theta)+j*sin(theta)')
disp(' ')

% Verifying Euler's Identity
realz=r*cos(theta);      % Compute real part of z
imagz=r*sin(theta);      % Compute imaginary part of z
s=['z = ' num2str(realz) ' + j*' num2str(imagz)];
disp('The complex number z in cartesian format is:')
disp(s)