如何在 Python/Matlab 中的极坐标网格上绘制多个磁滞回线?

How to plot Multiple Hysteresis loops on polar grid in Python/Matlab?

我想在 Python 或 Matlab 中的极坐标网格上绘制多个磁滞回线(如下图所示,取自论文)。我知道如何在 matlab 中使用极坐标图函数,但我正在为如何解决这个问题而苦苦挣扎,尤其是重新调整滞后环路以及如何定义 theta 和 rho 以便每个环路以特定角度出现。

如果您不依赖一个轴上的图形。 假设我们有两个矩阵 HystXHystY 包含 N 行,每行描述第 i 个磁滞回线。

polar(0,1.5)  % Hack to get 8 smaller
hold on
polar(1:0.1:2*pi(),abs(sin(1:0.1:2*pi()))) % Print the eight
set(gcf,'units','centimeters')
set(gca,'units','centimeters')

AXpos=get(gca,'position')  % axes position
AXCentre=[AXpos(1)+0.5*AXpos(3);AXpos(2)+0.5*AXpos(4)];
Radius=min(AXpos(3:4));

N=18;   % Number of hysteresis loops

Theta=0:1/N:1-1/N;  % distribute Theta evenly
Theta=2*pi()*Theta; % distribute Theta in range of (0,2Pi)

% coordinates of centres of minor axes relative to major axes centre.
axX=2/3*Radius*cos(Theta);
axY=2/3*Radius*sin(Theta);

% align the reference centre with centre of major axes, compensate dimensions of minor axes
axX=axX+AXCentre(1)-0.5; % -0.5 for axes with width/height = 1
axY=axY+AXCentre(2)-0.5;

for ii=1:N
   MinorAX=axes('units','centimeters','position',[axX(ii),axY(ii),1,1])
   line=('xdata',HystX(ii,:),'ydata',HystY(ii,:),'parent',MinorAX(ii))
end

set(MinorAX,'visible','off')  %disappear minor axes;

如果你想把所有东西都放在一个轴上你可以使用这个例子: 在第一部分中,我生成了一组 "hysteresis loops",然后我在极坐标中绘制了“8”,最后绘制了磁滞回线。 这是基于这样一个事实,即 polar 情节在 "real, hidden axes" 中创建了 "fake axes"(set(gca,'visible','on') 将显示它们)。

close all;clear all;        % get rid off variables and figures
N=12;                       % number of hysteresis loops
HystX=zeros(N,100);         % X-values for loops
HystY=HystX;                % Y-values for loops
TempH=2*pi()*[0:0.01:1];    % Base for loops' content
TempV=2*pi()*[0:1/N:1-1/N]; % Phase lead to differ the loops; position of the loop in axes
%% Calclate the loops' cooordinates
for ii=1:N
  for jj=1:101
    HystX(ii,jj)=0.1*cos(TempH(jj));
    HystY(ii,jj)=0.1*sin(TempH(jj)+TempV(ii));
  end
end

%% Plot the content oi polar axes
polar(0,2)
hold on
polar(TempH,abs(sin(TempH)))
% set(gca,'visible','on')

%% Plot the hysteresis loops.
for ii=1:12
  line('xdata',HystX(ii,:)+(1.5*cos(TempV(ii))),...
       'ydata',HystY(ii,:)+(1.5*sin(TempV(ii))))
end