Different Xticks and labels in subplot
조회 수: 11 (최근 30일)
이전 댓글 표시
How do I get the xticks, xlabels, yticks and ylabels for both subplots? I have tried the commented sections, but it didn't work. Here is my code:
syms x
Koppel = heaviside(x)-2*heaviside(x-6)+heaviside(x-10);
t = -2:0.005:12;
t1 = 0:0.005:10;
Koppel = double(subs(Koppel,x, 1.*t));
Poly5 = (3*t1)/16 - (5*(t1/5 - 1).^3)/8 + (3*(t1/5 - 1).^5)/16 - 7/16;
%% plot
setAcademicFigureSettings
figure
ax1 = subplot(2,1,1)
plot([-2 0], [0 0],t1,Poly5,[10 12], [1 1],'Color',1/255.*[0,46,101])
ylabel('Positie [rad]')
xlabel('Tijd [s]')
title('Bang-bang methode', 'FontSize',22)
% xticks([0 6 10]);
% xticklabels(ax1, {'t_{a}', 't_{switch}','t_{b}'}); % gewenste xtick labels
% yticks(ax1, [0 1]);
% yticklabels(ax1, {'\theta_{a}', '\theta_{b}'}); % gewenste xtick labels
ax2 = subplot(2,1,2)
plot(t,Koppel)
grid on
ylabel('Koppel [Nm]')
xlabel('Tijd [s]')
% xticks(ax1, [0 6 10]);
% xticklabels(ax1, {'t_{a}', 't_{switch}','t_{b}'}); % gewenste xtick labels
% yticks(ax1, [0 1]);
% yticklabels(ax1, {'\theta_{a}', '\theta_{b}'}); % gewenste xtick labels
% xticks(ax2,[0 6 10])
% xticklabels(ax2,{'t_{a}', 't_{switch}','t_{b}'})
% yticks(ax2,[-1 1])
% yticklabels(ax2,{'-T_{nom}', 'T_{nom}'})
% ylim(ax2,[-1.5 1.5])
% %set(ax2,'TickLabelInterpreter','tex')
댓글 수: 3
Walter Roberson
2023년 5월 11일
What difference is there between what you get and what you expect?
syms x
Koppel = heaviside(x)-2*heaviside(x-6)+heaviside(x-10);
t = -2:0.005:12;
t1 = 0:0.005:10;
Koppel = double(subs(Koppel,x, 1.*t));
Poly5 = (3*t1)/16 - (5*(t1/5 - 1).^3)/8 + (3*(t1/5 - 1).^5)/16 - 7/16;
%% plot
%setAcademicFigureSettings
figure
ax1 = subplot(2,1,1)
plot([-2 0], [0 0],t1,Poly5,[10 12], [1 1],'Color',1/255.*[0,46,101])
ylabel('Positie [rad]')
xlabel('Tijd [s]')
title('Bang-bang methode', 'FontSize',22)
% xticks([0 6 10]);
% xticklabels(ax1, {'t_{a}', 't_{switch}','t_{b}'}); % gewenste xtick labels
% yticks(ax1, [0 1]);
% yticklabels(ax1, {'\theta_{a}', '\theta_{b}'}); % gewenste xtick labels
ax2 = subplot(2,1,2)
plot(t,Koppel)
grid on
ylabel('Koppel [Nm]')
xlabel('Tijd [s]')
xticks(ax1, [0 6 10]);
xticklabels(ax1, {'t_{a}', 't_{switch}','t_{b}'}); % gewenste xtick labels
yticks(ax1, [0 1]);
yticklabels(ax1, {'\theta_{a}', '\theta_{b}'}); % gewenste xtick labels
xticks(ax2,[0 6 10])
xticklabels(ax2,{'t_{a}', 't_{switch}','t_{b}'})
yticks(ax2,[-1 1])
yticklabels(ax2,{'-T_{nom}', 'T_{nom}'})
ylim(ax2,[-1.5 1.5])
%set(ax2,'TickLabelInterpreter','tex')
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Axes Appearance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
