Matrix manipulation and interpolation

1 visualización (últimos 30 días)
MSP
MSP el 19 de Nov. de 2017
Comentada: Jan el 20 de Nov. de 2017
Hello here is my problem,Pls see the image for a simple understanding And thanks in advance
I have a matrix M (for easy visualization purpose a 3*3). I need to use this values to get a bigger matrix whose size is not neccessarily multiples of 3 (like 6*6)>It might be any number for example 11*11>Pls refer to image 2(matrix). So I want the the values to be interpolated and extapolated at the grey cells whereas the pink are my data points M. I have done upto this, where my input values can start from only index (1,1) which I dont want
m=magic(3)
S=size(m)
[Xi,Yi] = meshgrid(1:1:S(2),1:1:S(1));
[Xo,Yo] = meshgrid(1:0.5:S(2)+1,1:0.5:S(1)+1);
out = interp2(Xi,Yi,m, Xo,Yo)

Respuesta aceptada

Jan
Jan el 20 de Nov. de 2017
Editada: Jan el 20 de Nov. de 2017
Maybe you want to shifft the output one element to the right and bottom:
[Xo,Yo] = meshgrid(0.5:0.5:S(2)+0.5, 0.5:0.5:S(1)+0.5);
  2 comentarios
MSP
MSP el 20 de Nov. de 2017
Oh thanks but do you know any function that will extrapolate all the Nans at the top and left part
Jan
Jan el 20 de Nov. de 2017
There is no unique method for extrapolating the values. You have to define at first, which model you want to use. Perhaps you want to repeat the existing marginal numbers, or fit a spline or B-spline to the data. Maybe you want a linear extrapolation or there is a fixed value on the edge.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by