Different Xticks and labels in subplot

14 visualizaciones (últimos 30 días)
Toon Van Dyck
Toon Van Dyck el 11 de Mayo de 2023
Comentada: Toon Van Dyck el 12 de Mayo de 2023
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 comentarios
Walter Roberson
Walter Roberson el 11 de Mayo de 2023
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 el 12 de Mayo de 2023
The function setAcademicFigureSetting was the problem. Thanks a lot.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Axes Appearance en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by