% Shift a convolution kernel, or any other function of funny wrapped
% coordinates like those used in the FFT, so that it can be plotted
% centered (in 1D). Provide a coordinate axis that works with it.
function [k2,x2] = kernel_shift(kernel, dx)
% kernel = convolution kernel.
% dx = sample interval.

N = numel(kernel);
x = [0:N/2, -ceil(N/2-1):-1] * dx;

offset = -ceil(N/2);
k2 = shift(kernel, offset);
x2 = shift(x, offset);