Interpolation via Zero Padding
33 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Zaref Li
am 3 Jan. 2024
Kommentiert: Sulaymon Eshkabilov
am 5 Jan. 2024
Hello everyone,
Below is the interpolation code with zero padding. But I want to make some changes to this code. I want to interpolate by a factor of 5 in the time domain using the following. Which factor component should I change here? Can you help me?
N = 30;
x = (0:N-1)/N;
Ni = 300;
xi = (0:Ni-1)/Ni;
f = exp.(sin.(2*pi*x));
ft = fftshift(fft(f))
Npad = floor(Int64, Ni/2 - N/2)
ft_pad = [zeros(Npad); ft; zeros(Npad)];
f_interp = real(ifft( fftshift(ft_pad) )) *Ni/N ;
plot(x,f, label="Original samples",markershape=:circle)
plot!(xi,f_interp,label="Interpolated values")
0 Kommentare
Akzeptierte Antwort
Sulaymon Eshkabilov
am 3 Jan. 2024
Is this what you are trying to get:
N = 30;
x = (0:N-1)/N;
Ni = 5 * N; % By a factor "5"
xi = (0:Ni-1)/Ni;
f = exp(sin(2*pi*x));
ft = fftshift(fft(f));
Npad = floor((Ni/2 - N/2));
ft_pad = [zeros(1, Npad), ft, zeros(1, Npad)];
f_interp = real(ifft(fftshift(ft_pad))) * Ni / N;
plot(x, f, 'ro', 'MarkerFaceColor', 'y', 'DisplayName',"Original samples"), hold on
plot(xi, f_interp, 'b-', 'LineWidth',2, 'DisplayName',"Interpolated values")
legend('show')
xlabel('x')
ylabel('f(x)')
grid on
2 Kommentare
Sulaymon Eshkabilov
am 5 Jan. 2024
It would be something like this one:
N = 16;
x = (0:N-1)/N;
Ni = 5*N; % By a factor "5"
xi = (0:Ni-1)/Ni;
f = exp(cos(2*pi*0.2*x));
ft = fftshift(fft(f));
Npad = floor((Ni/2 - N/2));
ft_pad = [zeros(1, Npad), ft, zeros(1, Npad)];
f_interp = real(ifft(fftshift(ft_pad))) * Ni / N;
plot(x, f, 'ro', 'MarkerFaceColor', 'y', 'DisplayName',"Original samples"), hold on
plot(xi, f_interp, 'b-', 'LineWidth',2, 'DisplayName',"Interpolated values")
legend('show', 'Location', 'Best')
xlabel('x')
ylabel('f(x)')
grid on
Weitere Antworten (1)
Balaji
am 3 Jan. 2024
Hi Zaref
To interpolate by 'interpolate_size=5' you can assign
Ni = N*interpolate_size
You can modify your code as below:
N = 30;
x = (0:N-1)/N;
interpolate_size = 5;
Ni = N*interpolate_size;
xi = (0:Ni-1)/Ni;
f = exp(sin(2*pi*x));
ft = fftshift(fft(f));
Npad = floor(Ni/2 - N/2);
ft_pad = [zeros(1, Npad) ft zeros(1, Npad)];
f_interp = real(ifft( fftshift(ft_pad) ))*Ni/N ;
figure(1)
stem(x,f)
figure(2)
stem(xi,f_interp)
Hope this helps
Balaji
0 Kommentare
Siehe auch
Kategorien
Mehr zu Filter Analysis 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!