Different Xticks and labels in subplot

14 次查看(过去 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
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