Tuesday 22 October 2013

How to change the GRID size and Grid labels (of x, y, and z axis indices) in Matlab Plots?

1 . Simplest command is:

>> grid minor


2. If we need to customize the grid-line locations, then

a. Equal spacing:

set(gca,'xtick',[0:13:100])
set(gca,'ytick',linspace(-50,50,0))


b. Unequal spacing

xGrid = [-5 -2 -0 4 6 9]; %This need not cover the entire range of x. Where ever %grid-lines are needed we can have


set(gca,'ytick',[-50:2:0])

set(gca,'xtick',xGrid)

c. Example of playing with grid size and grid labels
%Code search space (x-axis) indices
xx = codeChipInd-1;
for ii = 1:2:length(xx)
  xTickLabel1(ii).a = num2str(xx(ii).*(fCode/fSamp), 4);
end
xlbl = {xTickLabel1.a};

%Frequency search space (y-axis) indices
yy = freqSearchRange(1:1:end);
for ii = 1:1:length(yy)
  yTickLabel1(ii).a = num2str(yy(ii), 4);
end
ylbl = {yTickLabel1.a};

% Set the grid-lines -- x and y indices where grid lines to be shown
%Define the grid-line locations
set(gca, 'XTick',[1:1200:length(xx)]); % selecting every 1200 samples (100 chips) (12.276 MHz Fs=> 12 samples per code)

set(gca, 'YTick',[1:10:length(yy)]); %selecting every 10 frequency bin

% Label the grid-lines that are selected above.
set(gca,'XTickLabel',xlbl(1:1200:end))
set(gca,'YTickLabel',ylbl(1:10:end))


GPS Acquisition: Delay and Frequency search space

No comments:

Post a Comment