Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help writing two matlab function that do the following: 1) 2) Create a fu

ID: 2248255 • Letter: I

Question

I need help writing two matlab function that do the following:

1)

2)

Create a function called DisplayPhasor that displays a given complex value in both rectangular and polar form. The polar form should display the angle in degrees rather than radians. The function should accept a single complex number as an argument, along with an optional text string that can be used as a label. A usage example is: >> z = 5 + j*12; DisplayPhasor (Z) Z = 5+121 = 13 > DisplayPhasor (2, 'ZLoad') ZLoad = 3+41 = 5

Explanation / Answer

function Z = DisplayPhasor(n,label1)
mag = abs(n);
phs = angle(n)*180/pi;
if nargin==1%gives number of inputs entered
Z = [num2str(n) ' = ' num2str(mag) ' < ' num2str(phs) ' deg '];
else
Z = [label1 ' = ' num2str(n) ' = ' num2str(mag) ' < ' num2str(phs) ' deg '];
end

output:

function Z = BuildPhasor(mag, phs)
cmplx_nbr = mag*cosd(phs)+mag*sind(phs)*1i;
Z = ['Z = ' num2str(cmplx_nbr) ' = ' num2str(mag) ' < ' num2str(phs) ' deg '];
end