MATLAB: How to change the xlabel on the graph with the amount of xticks i have on it

axiscircularcoefficientcylindersdynamicsflowfluidformatformattinggraphMATLABplotpointspressuretickx axisxtick

I need to have a step size of 2 which is seen with 0:2:360 but I want my final graph to include a range of 0-360 with an interval of 40 on the x-axis. I'm calculating the pressure coefficient on a circular cylinder and realize that when I graph it the x-axis is clouded with numbers. I want to reduce the numbers shown in the x-axis while still retaining the tick marks.
% CP for G=0
u=1
a=1
G=degtorad(0)
t=0:.2:2*pi;
ti=radtodeg(t);
cp = 1 - 4*sin(t).^2 + 2* G / (pi*a*u) *sin(t) - (2* G/ (pi*a*u) )^2 ;
cp_sim = 1 - 4*sin(t).^2 ;
L = - 1.225*u*G;
figure(1);
h=plot(ti,cp,ti,cp_sim,'--r');
set(gca,'xtick',0:2:360);
xlim([0 360]);
title('Pressure coefficient around Circular Cylinder');
xlabel('Theta')
ylabel('Cp')
legend('Lifting solution','Non-Lifting solution');
grid on;

Best Answer

I’m not certain what you want.
Experiment with this:
% CP for G=0
u=1;
a=1;
G=degtorad(0);
t=0:.2:2*pi;
ti=radtodeg(t);
cp = 1 - 4*sin(t).^2 + 2* G / (pi*a*u) *sin(t) - (2* G/ (pi*a*u) )^2 ;
cp_sim = 1 - 4*sin(t).^2 ;
L = - 1.225*u*G;
figure(1);
h=plot(ti,cp,ti,cp_sim,'--r');
set(gca,'xtick',0:2:360);
xlim([0 360]);
title('Pressure coefficient around Circular Cylinder');
xlabel('Theta')
ylabel('Cp')
legend('Lifting solution','Non-Lifting solution');
grid on;
xts = get(gca, 'XTick');
set(gca,'XTickLabel',[]);
set(gca, 'XTick', xts(1:4:end), 'XTickLabel',xts(1:4:end), 'XTickLabelRotation',-80, 'FontSize',7)