Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Zero-padding

Subject: Zero-padding

From: Susan

Date: 28 Jan, 2011 15:16:04

Message: 1 of 5

Hi,

I have a data file that has 1024 values and I would like to pad this out to N times the amounts of data points, e.g. 2*N = 2048, etc., so I can get a better interpolation before processing. I have tried applying zeros() but it just gives me N number of zeros after my data.

How can I pad the data evenly with zeros?

Thanks!

Subject: Zero-padding

From: Wayne King

Date: 28 Jan, 2011 15:31:04

Message: 2 of 5

"Susan" wrote in message <ihumjk$9c0$1@fred.mathworks.com>...
> Hi,
>
> I have a data file that has 1024 values and I would like to pad this out to N times the amounts of data points, e.g. 2*N = 2048, etc., so I can get a better interpolation before processing. I have tried applying zeros() but it just gives me N number of zeros after my data.
>
> How can I pad the data evenly with zeros?
>
> Thanks!

Hi Susan, do you mean you want to upsample your signal?

x = randn(1024,1);
x = upsample(x,2); % requires Signal Processing Toolbox

% or
x = randn(1024,1);
x = upsample(x,2,1);

The latter will upsample the odd "phase" of x.

Hope that helps,
Wayne

Subject: Zero-padding

From: Sean de

Date: 28 Jan, 2011 17:04:04

Message: 3 of 5

"Susan" wrote in message <ihumjk$9c0$1@fred.mathworks.com>...
> Hi,
>
> I have a data file that has 1024 values and I would like to pad this out to N times the amounts of data points, e.g. 2*N = 2048, etc., so I can get a better interpolation before processing. I have tried applying zeros() but it just gives me N number of zeros after my data.
>
> How can I pad the data evenly with zeros?
>
> Thanks!

X= your_signal;
X2 = zeros(length(Your_signal)*2,1);
X2(1:2:end) = X;

Subject: Zero-padding

From: Greg Heath

Date: 30 Jan, 2011 05:59:41

Message: 4 of 5

On Jan 28, 10:16 am, "Susan " <Cooma_ki...@yahoo.co.uk> wrote:
> Hi,
>
> I have a data file that has 1024 values and I would like to pad this out to N times the amounts of data points, e.g. 2*N = 2048, etc.,  so I can get a better interpolation before processing.  I have tried applying zeros() but it just gives me N number of zeros after my data.
>
> How can I pad the data evenly with zeros?
>
> Thanks!

I don't understand.

Do you want to insert zeros between each pair of points
or do you want to insert interpolated values between
each pair of points by zeropadding the ifft (i.e, Fourier
interpolation)?

Hope this helps.

Greg

Subject: Zero-padding

From: Arturo Moncada Torres

Date: 17 Mar, 2011 15:35:05

Message: 5 of 5

"Susan" wrote in message <ihumjk$9c0$1@fred.mathworks.com>...
> Hi,
>
> I have a data file that has 1024 values and I would like to pad this out to N times the amounts of data points, e.g. 2*N = 2048, etc., so I can get a better interpolation before processing. I have tried applying zeros() but it just gives me N number of zeros after my data.
>
> How can I pad the data evenly with zeros?
>
> Thanks!

Hello Susan.

Try this function

http://www.mathworks.com/matlabcentral/fileexchange/30782-zero-padding-2n

Regards!

Arturo M.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us