필터 지우기
필터 지우기

How to match two y axes of the yyaxis , so that their 0 points are aligned

조회 수: 39 (최근 30일)
Hello guys,
In the following code, I am trying to plot using yyaxis.. However, in the plot the 0 values of the y axis are offset. How can I make them aligned? I have attached a snapshot of the resulting plot.
Thanks in advance.. Have a nice day....
%%% Pedal torque and Motor Target torque
t_pedal = (Trip.Data.Signals(33).Time)' ;
T_pedal = (-Trip.Data.Signals(33).Value*(ampl_fac*4/12000))' ;
T_in = timeseries((T_pedal),(t_pedal));
figure (2)
yyaxis left
ax = gca;
ax.YLim = [-100 100];
plot(t_pedal,T_pedal,'y');
hold on
t_tar_mot = Trip.Data.Signals(9).Time ;
T_tar_mot = -(Trip.Data.Signals(9).Value) ;
plot(t_tar_mot,T_tar_mot);
ylabel ('Motor Torque [Nm]')
xlabel('Time [s]')
% legend('pedal torque','motor torque')
% grid minor
%%% Cadence and velocity
t_cd = Trip.Data.Signals(32).Time ;
cd = Trip.Data.Signals(32).Value/30 ;
CD_act = timeseries(cd,t_cd);
yyaxis right
ax2 = gca;
ax2.YLim = [-100 100];
plot (t_cd,cd,'b');
hold off
ylabel ('Cadence (rpm)')
xlabel('Time [s]')
legend('pedal torque','motor target torque','cadence')

채택된 답변

VBBV
VBBV 2022년 10월 21일
편집: VBBV 2022년 10월 21일
T_in = timeseries((T_pedal),(t_pedal));
figure (2)
yyaxis left
plot(t_pedal,T_pedal,'y');
hold on
t_tar_mot = Trip.Data.Signals(9).Time ;
T_tar_mot = -(Trip.Data.Signals(9).Value) ;
plot(t_tar_mot,T_tar_mot);
ax = gca; %
ax.YLim = [-100 100]; %
  댓글 수: 2
VBBV
VBBV 2022년 10월 21일
ax = gca; %
ax.YLim = [-100 100]; %
Put these lines after 2nd plot call as axes are refreshed with 2nd plot function
RITAM BASU
RITAM BASU 2022년 10월 21일
It works now... Thank you... Have a nice day.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by