Sinc Interpolation without using predefined function
显示 更早的评论
I need to write a code that does linear interpolation. (without using interp1) My function has 3 inputs (n,x,n2). Vector n contains the sample points, and x contains the corresponding values, x(n). Vector n2 contains the coordinates of the query points. My code is this:
function y = sinc_interp(n,x,n2)
y = zeros(length(n2),1);
for i=1:length(n2)
y(i) = sum(x.*sinc(n2(i)- n));
end
end
I think the formula is ok (It is the Shannon formula). The problem is that for various input functions, it doesn't look good. For example:
a = 0.7;
N = 10;
n = 0:N;
x = n.*a.^n + 1;
n2 = linspace(0,10,1000);
figure(1)
plot(n2,n2.*a.^n2 + 1)
y3 = sinc_interp(n,x,n2);
figure(2)
plot(n2,y3)

采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
