Sunday, November 27, 2016

If you are wondering how to plot an empty grid in MATLAB, scaled vertically and horizontally by pi, the simple code below might help you:

 fig_piGrid = figure;                                                               
    axis([0, 2*pi, -4, 4])                                                            
    set(gca,'xtick', 0 : pi/2 : 2*pi,...
        'xticklabel',{'0' '\pi/2' '\pi' '3\pi/2' '2\pi'}, 'xgrid', 'on',...
        'ytick', -pi : pi/2 : pi,...
        'yticklabel',{'-\pi' '-\pi/2' '0' '\pi/2' '\pi'}, 'ygrid', 'on',...
        'ycolor', 'b', 'gridLineStyle', '-', 'linewidth', 1)         
    set(fig_piGrid, 'Units','centimeters','position', [1, 1, 29.7, 21],...            
    'PaperUnits','centimeters','PaperSize',[29.7, 21],'PaperPositionMode','auto')
print('H:\...\fileName','-dpdf')                                                   % set the path to save the figure





You can simply customize the grid by changing, adding or removing some parameters.  

Example: plot phase change of a simple oscillation with the frequency f=1:


Remember you should first plot then set figure properties. Otherwise "plot" will overwrite previous settings.