전동기의 동력과 토크를 같은 그래프에 그려 볼 것입니다. 델타 스타 구성을 그리기 위해 사이클을 사용했습니다. 이중 기어 시스템도 있으므로 각 구성에 대해 2 시리즈의 데이터 (전력 및 토크)를 플로팅합니다. 나는 이것을 시도했지만 두 번째 루프에서는 첫 번째가 아니라 두 번째 축에 그려진다. 내가 MATLAB 2015을 사용, 그래서 내가 yyaxis function
Matlab - 다른 y 축에 플롯하는 방법
clc; clear all;close all
tau=[8.823;1.604]; %in ordine decrescente
n_gamme=length(tau);
data=[22 22;575 1200;1500 6000;365 175];%P,Ginocchio,rpm max,C
names={'Star';'Delta'};
nN=zeros(2);nmax=zeros(2);M_N=zeros(2); %inizializzo
for i=1:n_gamme %contatore gamme
% j=1; se non ho stella-triangolo
for j=1:2 %contatore stella-triangolo
P=data(1); %potenza max
nN(i,j)=data(2,j)./tau(i); %rpm, ginocchio
nmax(i,j)=data(3,j)/tau(i); %giri max
M_N(i,j)=data(4,j)*tau(i); %coppia max
end
end
PL=['r','r-';'g','g-'];
% j=1; %se non ho stella-triangolo
for j=1:2 %contatore stella-triangolo
% subplot(length(tau),1,j);
% figure
x1(j,:) = linspace(0,nN(1,j)); %numero di giri da 0 al ginocchio 1
x2(j,:) = linspace(nN(1,j),nmax(1,j)); %da ginocchio 1 a max 1
x3(j,:) = linspace(0,nN(2,j)); %da 0 a ginocchio 2
x4(j,:) = linspace(nN(2,j),nmax(2,j)); %da ginocchio 2 a max 2
C_1(1,j)=M_N(1,j); %coppia costante 1 marcia
C_2(j,:)=30*P*1000./(pi*x2(j,:)); %coppia 1 marcia
C_3(2,j)=M_N(2,j); %coppia costante 2 marcia
C_4(j,:)=30*P*1000./(pi*x4(j,:)); %coppia 2 marcia
ax1 = gca;
plot(ax1,[0,nN(1,j)],[C_1(1,j) C_1(1,j)],PL(1,j),'LineWidth',2/j^2) %I coppia costante
hold on
plot(ax1,x2(j,:),C_2(j,:),PL(2,j),'LineWidth',2/j^2) %coppia I
plot(ax1,[max(x2(j,:)),nN(2,j)],[C_3(2,j) C_3(2,j)],PL(1,j),'LineWidth',2/j^2) %II coppia costante
plot(ax1,x4(j,:),C_4(j,:),PL(2,j),'LineWidth',2/j^2) %coppia II
ylim([0 3500])
ylabel(ax1,'Torque [Nm]'); %# Add a label to the left y axis
set(ax1,'Box','off');%# Turn off the box surrounding the whole axes
axesPosition = get(gca,'Position');
ax2 = axes('Position',axesPosition,...
'YLim',[0 30],... %# and a different scale
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none',...
'XColor','b','YColor','b',...
'Box','off'); %# ... and no surrounding box
hold on
m=P./nN; %pendenza potenza
P_1(j,:)=m(1,j).*x1(j,:); %potenza 1 marcia
P_2(1,j)=P; %Potenza costante 1 marcia
P_3(j,:)=m(2,j).*x3(j,:); %Potenza 2 marcia
P_4(2,j)=P; %Potenza costante 2 marcia
plot(ax2,x1(j,:),P_1(j,:),'b--')
plot(ax2,[max(x1(j,:)),nmax(1,j)],[P P],'b--')
plot(ax2,x3(j,:),P_3(j,:),'b--')
plot(ax2,[max(x3(j,:)),nmax(2,j)],[P P],'b--')
ylabel(ax2,'Power [kW]');
linkaxes([ax1 ax2],'x'); %lega tra di loro gli assi,
grid on
grid minor
end
어떻게 내가 당신이 원하는 플롯의 종류 plotyy
를 사용해야합니다
맞아. 내가 해결 했어, 고마워. – Andrea