Filter löschen
Filter löschen

I need help with this plot

1 Ansicht (letzte 30 Tage)
Jerry Walker
Jerry Walker am 31 Mär. 2013
This code should have net B field rotating in opposite directions. I'm at a loss to make it work.
clc
clear all
close
disp('Jerry Walker''s Fantastic Engineering Adventure')
disp('EEL 3216 Problem4.4');
fprintf('\n')
format short
% MATLAB Example of CCW Field Rotation
% M-file to calculate the net magnetic field produced
% by a three-phase stator with currents in normal a-b-c sequence % (not flipped).
% Set up the basic conditions
bmax = 1; % Normalize bmax to 1
freq = 60; % 60 Hz
w = 2*pi*freq; % angular velocity (rad/s)
% First, generate the three component magnetic fields
t = 0:1/60000:1/60;
Baa = sin(w*t) .* (cos(0) + j*sin(0));
Bbb = sin(w*t-2*pi/3) .* (cos(2*pi/3) + j*sin(2*pi/3));
Bcc= sin(w*t+2*pi/3) .* (cos(-2*pi/3) + j*sin(-2*pi/3));
% Calculate Bnet
Bnet = Baa + Bbb + Bcc;
% Calculate a circle representing the expected maximum
% value of Bnet
circle = 1.5 * (cos(w*t) + j*sin(w*t));
% Plot the magnitude and direction of the resulting magnetic
% fields. Note that Baa is black, Bbb is blue, Bcc is
% magneta, and Bnet is red.
% Switch sign for Bbb and Bcc
Btaa = sin(w*t) .* (cos(0) + j*sin(0));
Btbb = sin(w*t+2*pi/3) .* (cos(2*pi/3) + j*sin(2*pi/3));
Btcc= sin(w*t-2*pi/3) .* (cos(-2*pi/3) + j*sin(-2*pi/3));
% Calculate Bnet
Btnet = Btaa + Btbb + Btcc;
% Calculate a circle representing the expected maximum
% value of Bnet
circle = 1.5 * (cos(w*t) + j*sin(w*t));
% Plot the magnitude and direction of the resulting magnetic
% fields. Note that Baa is black, Bbb is blue, Bcc is
% magneta, and Bnet is red.
for ii = 1:length(t) % Plot the reference circle
subplot(2,1,1)
plot(circle,'k');
hold on;
% Plot the four magnetic fields
plot([0 real(Baa(ii))],[0 imag(Baa(ii))],'k','LineWidth',2);
plot([0 real(Bbb(ii))],[0 imag(Bbb(ii))],'b','LineWidth',2);
plot([0 real(Bcc(ii))],[0 imag(Bcc(ii))],'m','LineWidth',2);
plot([0 real(Bnet(ii))],[0 imag(Bnet(ii))],'r','LineWidth',3);
legend('Baa','Bbb','Bcc','Bnet')
axis square;
axis([-2 2 -2 2]);
title('Magnetic Flux Versus Time');
drawnow;
% Plot the reference circle
subplot(2,1,2)
plot(circle,'k');
% Plot the four magnetic fields
plot([0 real(Btaa(ii))],[0 imag(Btaa(ii))],'k','LineWidth',2);
plot([0 real(Btbb(ii))],[0 imag(Btbb(ii))],'b','LineWidth',2);
plot([0 real(Btcc(ii))],[0 imag(Btcc(ii))],'m','LineWidth',2);
plot([0 real(Btnet(ii))],[0 imag(Btnet(ii))],'r','LineWidth',3);
legend('Btaa','Btbb','Btcc','Btnet')
axis square;
axis([-2 2 -2 2]);
title('Magnetic Flux Versus Time');
drawnow;
hold off;
end

Antworten (1)

Image Analyst
Image Analyst am 1 Apr. 2013
  1 Kommentar
Jerry Walker
Jerry Walker am 3 Apr. 2013
I watched the video twice. I used Ctrl C to stop the run and when clicking the error msg I was taken to the legend function. I'm not competent to modify this function. I placed a "%" before the two legend commands and ran the program. On this occasion I was taken to the subplot function. I'm not competent to modify this function. I must admit that I realy don't understand what happens in the video.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by