Different Xticks and labels in subplot

조회 수: 11 (최근 30일)
Toon Van Dyck
Toon Van Dyck 2023년 5월 11일
댓글: Toon Van Dyck 2023년 5월 12일
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
Unrecognized function or variable '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
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)
ax1 =
Axes with properties: XLim: [0 1] YLim: [0 1] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.1300 0.5838 0.7750 0.3412] Units: 'normalized' Show all properties
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)
ax2 =
Axes with properties: XLim: [0 1] YLim: [0 1] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.1300 0.1100 0.7750 0.3412] Units: 'normalized' Show all properties
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')
Toon Van Dyck
Toon Van Dyck 2023년 5월 12일
The function setAcademicFigureSetting was the problem. Thanks a lot.

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

답변 (0개)

카테고리

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

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by