help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making multiple plots, Octave 3.2.4


From: Allen.Windhorn
Subject: Making multiple plots, Octave 3.2.4
Date: Wed, 28 Apr 2010 09:11:38 -0500

I'm running Octave 3.2.4 from the Sourceforge binary on a Windows XP
system.  I'm trying to make two plots, each in its own window.  I use
Figure(1) and create the first plot (which displays OK), then figure(2)
and create the second, which displays its window (only the axes, no
data) and then hangs.  This is using the default gnuplot backend.
Switching to the fltk backend makes the whole program hang, with nothing
displayed.  Even plotting manually hangs it.

The code isn't too long, so I am appending it entire.  (Yes, it's messy
-- I'll clean it up when I get it working.)  The ShaftCurrData1 file has
to be run first to establish the data, then ShaftCurrent to process it
and show the plots.

------------------------------------------------------------------------
-
%ShaftCurrData1 -- Load data for ShaftCurrent
%
% Predefined variables:
%     permpoles -- permeance of pole arc for north, south, and
consequent
%                  96 rows, 3 columns (n, s, cons) for 4-pole
%     permjoints -- permeance of joints 1:12 for 6 segments (hard-coded)
%                   Joint 1 is between segment 12 and 1, joint 2 between
%                   segment 1 and 2, etc.
%
% Allen Windhorn, 28 April 2010
%
% Initialize things:
%
format short g; %Display results to more precision
%
% Pole permeances are normal for pole recurve
permpoles = [0.0771           0       0.001
      0.0889           0       0.001
        0.11           0       0.001
       0.155           0       0.001
       0.297           0       0.001
       0.954           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
       0.954           0       0.001
       0.297           0       0.001
       0.155           0       0.001
        0.11           0       0.001
      0.0889           0       0.001
      0.0771           0       0.001
           0      0.0771       0.001
           0      0.0889       0.001
           0        0.11       0.001
           0       0.155       0.001
           0       0.297       0.001
           0       0.954       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0       0.954       0.001
           0       0.297       0.001
           0       0.155       0.001
           0        0.11       0.001
           0      0.0889       0.001
           0      0.0771       0.001
      0.0771           0       0.001
      0.0889           0       0.001
        0.11           0       0.001
       0.155           0       0.001
       0.297           0       0.001
       0.954           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
       0.954           0       0.001
       0.297           0       0.001
       0.155           0       0.001
        0.11           0       0.001
      0.0889           0       0.001
      0.0771           0       0.001
           0      0.0771       0.001
           0      0.0889       0.001
           0        0.11       0.001
           0       0.155       0.001
           0       0.297       0.001
           0       0.954       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0       0.954       0.001
           0       0.297       0.001
        0.11           0       0.001
       0.155           0       0.001
       0.297           0       0.001
       0.954           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
           1           0       0.001
       0.954           0       0.001
       0.297           0       0.001
       0.155           0       0.001
        0.11           0       0.001
      0.0889           0       0.001
      0.0771           0       0.001
           0      0.0771       0.001
           0      0.0889       0.001
           0        0.11       0.001
           0       0.155       0.001
           0       0.297       0.001
           0       0.954       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0           1       0.001
           0       0.954       0.001
           0       0.297       0.001
           0       0.155       0.001
           0        0.11       0.001
           0      0.0889       0.001
           0      0.0771       0.001];

% 12 unequal joints, staggered, causes shaft current
permjoints = [10;3;10;3;10;3;10;3;10;3;10;3];
% 12 equal joints, no shaft current
% permjoints = [10;10;10;10;10;10;10;10;10;10;10;10];
% Poles are balaced
Phi_n = 1;
Phi_s = 1;
-------------------------------------------------------
%ShaftCurrent -- Calculate relative circulating flux for seg lams
% 
%
% Predefined variables:
%     permpoles -- permeance of pole arc for north, south, and
consequent
%                  96 rows, 3 columns (n, s, cons) for 4-pole
%     permjoints -- permeance of joints 1:12 for 6 segments (hard-coded)
%                   Joint 1 is between segment 12 and 1, joint 2 between
%                   segment 1 and 2, etc.
%
% Allen Windhorn, 10 March 2010
%
% Initialize things:
%
format short g; %Display results to more precision
% backend("fltk"); %Try alternate plotting routine
%
r2d = 180.0/pi;
d2r = 1.0/r2d;
TRUE = (1==1);
FALSE = (1==2);
%
% Fixed arrays:
%
% Array of pole permeances is doubled so we can scan around the circle
% just by indexing.
Pp = [permpoles; permpoles; permpoles(1, :)];
% Double up for convenience and add an element to the end
%
% Array of joint permeances is augmented by one element to allow looping
% back by indexing
Pj = [permjoints; permjoints(1)];
%
% Print header
%
disp(' ');
disp('           CALCULATE RELATIVE SHAFT POTENTIAL');
%
% Calculate the circulating flux variation
% for each position of the rotor
%
% Preload arrays
Pgn = zeros(12, 1);            %Gap permeances
Pgs = zeros(12, 1);
Pgo = zeros(12, 1);
Phi_p = [zeros(12, 1); Phi_n; Phi_s]; %Pole forcing flux
Phi_j = zeros(13, 1);           %Joint fluxes
Phi_m = zeros(96, 1);           %Net circulating flux vs. position
figure(1);
hold on
for m = 1:95  %24 positions per pole, 4 poles
  % Calculate potentials V for each position
  %
  % Calculate permeances from each half-segment to poles
  for k = 1:12
    for i = (8*k-7):(8*k)
      Pgn(k) += Pp(m+i, 1);
      Pgs(k) += Pp(m+i, 2);
      Pgo(k) += Pp(m+i, 3);
    end
  end
  % Sums
  Pgns = sum(Pgn);
  Pgss = sum(Pgs);
  %
  % Calculate diagonal terms
  Pv = Pj(1:12).+Pgn.+Pgs.+Pgo.+Pj(2:13);
  % Assemble permeance matrix from separate diagonal matrices
  Amat_m = diag([Pv; Pgns; Pgss], 0);   %Main diagonal
  Amat_l = diag([-Pj(1:12); 0; 0], 0);  %Left band
  Amat_r = diag([-Pj(2:13); 0; 0], 0);  %Right band
  % Shift left band left and right band right by one space
  RShift = eye(14)([14; [1:13]'], :);   %Permutation matrix, right
  Amat_l = Amat_l*RShift';              %Transpose reverses shift
  Amat_r = Amat_r*RShift;
  Amat = Amat_l.+Amat_m.+Amat_r;        %Combine
  % Add pole nodes
  Amat(13, 1:12) = -Pgn;
  Amat(14, 1:12) = -Pgs;
  Amat(1:12, 13) = -Pgn;
  Amat(1:12, 14) = -Pgs;
  % Calculate magnetic potentials
  V = Amat\Phi_p;
  % Calculate joint fluxes
  Phi_j = [V(1:11)-V(2:12); V(12)-V(1)].*Pj(1:12); %Probably wrong
  % Sum them to get net circulating flux for that position
  Phi_m(m+1) = sum(Phi_j);
  plot(Phi_j);
end
hold off;
figure(2);
plot(Phi_m);
-------------------------------------------------------------------

-- 
Allen Windhorn, P.E. (MN), CEng  (507) 345-2782
Kato Engineering
P.O. Box 8447, N. Mankato, MN  56002
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]