# Diagonal Interpolat​ion/Extrap​olation of a 1024 x 30 Matrix

32 views (last 30 days)
Christopher Gordon on 22 Feb 2021
Hello everyone,
I have a 2D matrix of spectra, (30 spectra, each being 1024 data points long). The 30 spectra are for various peaks along a 1024-pixel detector. I'm trying to interpolate (for the intermediate pixels) and extropolate (for the exterior pixels beyond the edge measurements) diagonally to get a 1024 x 1024 matrix. Could someone please help me by suggesting the most accurate way of doing this? I'm open to any methods, but I may need a little help with the implimentation. Any help would be greatly appreciated.
Christopher Gordon on 24 Feb 2021
Thank you both. I've attached two images, one shows all the individual spectra on a 2D axis, and the other is a surface plot that shows the peaks along the diagonal. I'd like to interpolate this matrix to give me the intermittent spectral plots for pixels that weren't measured directly.

Bjorn Gustavsson on 24 Feb 2021
What you can try for this is to align the main peaks, using something like this:
[~,idxPeaks] = max(I_spectras,[],2); % Here I assume that I_spectras are 30 x 1024
I_S_shifted = zeros(30,2048);
for i1 = 30:-1:1;
I_S_shifted(i1,1024-idxPeaks(i1)+[1:1024]) = I_spectras(i1,:);
end
imagesc(I_S_shifted)
Then you might get somewhere by interpolating I_S_shifted after which you might reverse-shift the spectras (how easy that is to do depends on how simple the shifts of the peaks are in the first place.) This works under the assumption that the shape of the peaks varies very slowly between neighboring spectra. This might be useful or not, If this is not good enough one might take a further step in scaling the spectra as well to line up additional features, but that's for later.
HTH
Bjorn Gustavsson on 2 Mar 2021