How to use sinc interpolation

I built a matrix 'sim'
sim=[];
for m=1:7
for n=1:7
sim(m,n)=m^2+n^2;
end
end
sim =
2 5 10 17 26 37 50
5 8 13 20 29 40 53
10 13 18 25 34 45 58
17 20 25 32 41 52 65
26 29 34 41 50 61 74
37 40 45 52 61 72 85
50 53 58 65 74 85 98
and I want to use sim(1,:) sim(3,:) sim(5,:) sim(7,:) to interp sim(2,7) by sinc interpolation
There is subroutine
function f=sincinterp2b(x,y,g,intx,inty)
f=0;
[mm,nn] = size(g);
for m=mm:-2:1
for n=1:nn
switch m
case 7
eq=0;
eq= g(m,n).*sinc((x/intx)-n).*sinc((y/inty)-1);
case 6
eq=0;
eq= g(m,n).*sinc((x/intx)-n).*sinc((y/inty)-2);
case 5
eq=0;
eq= g(m,n).*sinc((x/intx)-n).*sinc((y/inty)-3);
case 4
eq=0;
eq= g(m,n).*sinc((x/intx)-n).*sinc((y/inty)-4);
case 3
eq=0;
eq= g(m,n).*sinc((x/intx)-n).*sinc((y/inty)-5);
case 2
eq=0;
eq= g(m,n).*sinc((x/intx)-n).*sinc((y/inty)-6);
case 1
eq=0;
eq= g(m,n).*sinc((x/intx)-n).*sinc((y/inty)-7);
end
f=f + eq;
end
end
I use sincinterp2b(6.5,5.5,sim,1,2) to interp sim(2,7). but its answer is wrong. Where is my mistake

Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Asked:

on 8 Feb 2016

Community Treasure Hunt

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

Start Hunting!