%% Putting pi on the line
% How to use 'pi' as an xtick label

%% Make a filter

% This is a Butteworth low-pass filter with cut-off frequency at 0.3 pi.
[b, a] = butter(5,0.3);

%% Frequency response plot

[H,w] = freqz(b,a);

close all

figure(1), clf
p1 = plot(w, abs(H));

%% Use 0, pi/2, and pi as xticks
% 'gca' means 'get current axis'
% You can set parameters of the graph using 'set'

set(gca, 'xtick', [0, pi/2, pi]);

%% Change xtick labesl

set(gca, 'xtickLabel', {'0', '0.5p', 'p'})

%% Change font

set(gca, 'Fontname', 'symbol')

%% Increase font size

set(gca, 'Fontsize', 16)

%% Change axis limits 
% Notice that the horizontal axis extends beyond pi (ugly!)

xlim([0 pi])
ylim([0 1.1])       % some space is nice on top

%% Turn off box

box off

%% labels

h1 = xlabel('Frequency (\omega)');

%%
% Ooh, the xlabel font is 'symbol'. Lets change it:
set(h1, 'Fontname', 'Helvettica')

h2 = title('Frequency response');
set(h2, 'Fontname', 'Helvettica')

%% Lets make the frequency response curve thicker
% for better visibility

set(p1, 'LineWidth', 2)

%% Export figure to a file
% Matlab can save to a pdf file. Then there are no pixels
% in the graphics file - it has infinite resolution!

print -dpdf xtickpi_figure

%% Other parameters
% You can see what parameters are available using 'get'

get(gca)


