how to do zero padding for a vector?

109 ビュー (過去 30 日間)
g.p
g.p 2016 年 8 月 7 日
コメント済み: Superunknown 2023 年 4 月 5 日
please help. i have just started learning matlab .

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 8 月 7 日
A=[1 2 3]
B=[A zeros(1,3)]
  2 件のコメント
g.p
g.p 2016 年 8 月 8 日
THANKS ITS SIMPLE. IT WORKS.
ARPITKUMAR PATEL
ARPITKUMAR PATEL 2019 年 4 月 9 日
thanks, simple

サインインしてコメントする。

その他の回答 (1 件)

John BG
John BG 2016 年 8 月 8 日
Grupeet
the padding you may have in mind is the actual interpolation of zeros blocks after each symbol.
A=[1 2 3]
B=[A zeros(1,3)]
length of the padding
N=4
then
B=zeros(1,N*length(A))
=
0 0 0 0 0 0 0 0 0 0 0 0
B([1:N:end])
=
0 0 0
B([1:N:end])=A
=
1 0 0 0 2 0 0 0 3 0 0 0
In the example, appeneded DTFT code
it is clearly mentioned, the fft(x,2000) one-off zero padding in frequency domain helps reach the correct fft amplitude plot
Without FFT frequency zero padding
Fs = 1e3;
t = 0:0.001:1-0.001;
x = cos(2*pi*100*t)+sin(2*pi*202.5*t);
xdft = fft(x);
xdft = xdft(1:length(x)/2+1);
xdft = xdft/length(x);
xdft(2:end-1) = 2*xdft(2:end-1);
freq = 0:Fs/length(x):Fs/2;
figure(1);plot(freq,abs(xdft))
hold on;
figure(1);plot(freq,ones(length(x)/2+1,1),'LineWidth',2)
xlabel('Hz');ylabel('Amplitude');hold off;
with FFT frequency zero padding
xdft = fft(x,2000);
xdft = xdft(1:length(xdft)/2+1);
xdft = xdft/length(x);
xdft(2:end-1) = 2*xdft(2:end-1);
freq = 0:Fs/(2*length(x)):Fs/2;
figure(2);plot(freq,abs(xdft));
hold on;
figure(2);plot(freq,ones(2*length(x)/2+1,1),'LineWidth',2)
xlabel('Hz'); ylabel('Amplitude');
hold off;
Gurpreet would you please be so kind to mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John BG
  2 件のコメント
g.p
g.p 2016 年 8 月 8 日
GREAT ONE COMPLETELY HELPFULL. THANKS A LOT. CAN U TELL ME HOW TO PADD IN 000123 RATHER THAN 123000. PRE PADDING ??
Superunknown
Superunknown 2023 年 4 月 5 日
@John BGllorón

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by