Holooly Plus Logo

Question 8.67: MATLAB efficiently performs phasor calculations with complex......

MATLAB efficiently performs phasor calculations with complex numbers, but it can also be used to better visualize the concept of a rotating phasor. Recall that a sinusoidal signal is the real part of a phasor times e^{jωt}, where the ω term represents a rotation. The following MATLAB code demonstrates the rotation of a phasor and its projections onto the axes:

As given, the code plots a rotating phasor with a magnitude of one and an angle of zero. Run the code to understand how a rotating phasor creates a sinusoidal signal with its projection onto the real axis. Modify the MATLAB code to plot a rotating sum of phasors. Add the phasor 0.5 ∠90° to the original phasor and plot the two phasors head-to-tail. Also, plot the sum of the two phasors and the projection of the sum onto the real and imaginary axes. Rotate the results as shown in the original code.

% Create a figure and draw square axes
figure
axis([-1.5 1.5 -1.5 1.5]);
axis square
% Create reference axes
line([-2 2],[0 0],’Color’,’k’)
line([0 0],[-2 2],’Color’,’k’)
grid on
% Label the plot
title(‘Rotating Phasor Demonstration’)
xlabel(‘Real’)
ylabel(‘Imaginary’)
% Create a rotating unit phasor
% Plot its real and imaginary components
ArcStep = 100; % Increase to slow the rotations
Rotations = 2; % Number of rotations
for p = 0:pi/ArcStep:2*Rotations*pi
x = cos(p);
y = sin(p);
L1 = line([0 x],[0 0],’Color’,’b’,’LineWidth’,3);
L2 = line([0 0],[0 y],’Color’,’r’,’LineWidth’,3);
L3 = line([0 x],[0 y],’Color’,’m’,’LineWidth’,3);
drawnow
set(L1,’Visible’,’off’)
set(L2,’Visible’,’off’)
set(L3,’Visible’,’off’)
end
Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

The solution is presented as the following MATLAB code

The 'Blue Check Mark' means that either the MATLAB code/script/answer provided in the answer section has been tested by our team of experts; or the answer in general has be fact checked.

Learn more on how do we answer questions.

Script File

% Create a figure and draw square axes
figure
axis([-1.5 1.5 -1.5 1.5]);
axis square

% Create reference axes
line([-2 2],[0 0],'Color','k')
line([0 0],[-2 2],'Color','k')
grid on
% Label the plot
title('Rotating Phasor Demonstration')
xlabel('Real')
ylabel('Imaginary')
% Create a rotating unit phasor
% Plot its real and imaginary components
ArcStep = 100; % Increase to slow the rotations
Rotations = 2; % Number of rotations
M2 = 0.5;
P2 = pi/2;
for p = 0:pi/ArcStep:2*Rotations*pi
x = cos(p);
y = sin(p);
x2 = M2*cos(p + P2);
y2 = M2*sin(p + P2);
x3 = x + x2;
y3 = y + y2;
L1 = line([0 x3],[0 0],'Color','b','LineWidth',3);
L2 = line([0 0],[0 y3],'Color','r','LineWidth',3);
L3 = line([0 x],[0 y],'Color','m','LineWidth',3);
L4 = line([x x3],[y y3],'Color','m','LineWidth',3);
L5 = line([0 x3],[0 y3],'Color','g','LineWidth',4);

drawnow
set(L1,'Visible','off')
set(L2,'Visible','off')
set(L3,'Visible','off')
set(L4,'Visible','off')
set(L5,'Visible','off')
end
L3 = line([0 x],[0 y],'Color','m','LineWidth',3);
L4 = line([x x3],[y y3],'Color','m','LineWidth',3);
L5 = line([0 x3],[0 y3],'Color','g','LineWidth',4);
L1 = line([0 x3],[0 0],'Color','b','LineWidth',3);
L2 = line([0 0],[0 y3],'Color','r','LineWidth',3);

The required MATLAB code is presented above.

Related Answered Questions

Question: 8.54

Verified Answer:

Use node-voltage analysis to solve the problem.
Question: 8.53

Verified Answer:

Use node-voltage analysis to solve the problem.
Question: 8.51

Verified Answer:

The output phasor voltage appears across two eleme...