Matrix manipulation and interpolation

조회 수: 1 (최근 30일)
MSP
MSP 2017년 11월 19일
댓글: Jan 2017년 11월 20일
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)

채택된 답변

Jan
Jan 2017년 11월 20일
편집: Jan 2017년 11월 20일
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
MSP
MSP 2017년 11월 20일
Oh thanks but do you know any function that will extrapolate all the Nans at the top and left part
Jan
Jan 2017년 11월 20일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by