Filter löschen
Filter löschen

Matrix manipulation and interpolation

3 Ansichten (letzte 30 Tage)
MSP
MSP am 19 Nov. 2017
Kommentiert: Jan am 20 Nov. 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)

Akzeptierte Antwort

Jan
Jan am 20 Nov. 2017
Bearbeitet: Jan am 20 Nov. 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 Kommentare
MSP
MSP am 20 Nov. 2017
Oh thanks but do you know any function that will extrapolate all the Nans at the top and left part
Jan
Jan am 20 Nov. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by