FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > DSP

DSP comp.dsp newsgroup, mailing list

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-24-2007, 02:03 PM
jimosoto
Guest
 
Posts: n/a
Default zero padding

I'm really new to Matlab, I've been trying to write a code that windows
function with a user-specified window size. The only problem is it isn'
always and exact fit. To fix this I've written a for-loop that wil
hopefully zero pad the signal to fit the window. I can't seem to get th
thing to actually zero pad, though. Every time I try to enter a positiv
number, or a function that results in a positive number, it gives me a CA
error. I"m sure this is trivial and I'm just trying to go about it al
wrong, but I can't seem to figure it out. Thanks for the help. (the par
I'm having trouble with is the part after zeros)Code below:

function y = tester(filename,winLength,overlapLength)

x = wavread(filename);
lengthx = length(x);
y = [];

for j = (1:winLength-overlapLength+1:lengthx);
if (j+winLength-overlapLength < lengthx)
wy = hanning(winLength).* x(j:winLength+j-1);
else
zpx = [x,zeros(1,part I'm having trouble with)];
wy = hanning(winLength).* zpx(j:winLength+j-1);
end
end


Reply With Quote
  #2 (permalink)  
Old 02-25-2007, 08:27 AM
Fred Marshall
Guest
 
Posts: n/a
Default Re: zero padding


"jimosoto" <[email protected]> wrote in message
news:[email protected] ...
> I'm really new to Matlab, I've been trying to write a code that windows a
> function with a user-specified window size. The only problem is it isn't
> always and exact fit. To fix this I've written a for-loop that will
> hopefully zero pad the signal to fit the window. I can't seem to get the
> thing to actually zero pad, though. Every time I try to enter a positive
> number, or a function that results in a positive number, it gives me a CAT
> error. I"m sure this is trivial and I'm just trying to go about it all
> wrong, but I can't seem to figure it out. Thanks for the help. (the part
> I'm having trouble with is the part after zeros)Code below:
>
> function y = tester(filename,winLength,overlapLength)
>
> x = wavread(filename);
> lengthx = length(x);
> y = [];
>
> for j = (1:winLength-overlapLength+1:lengthx);
> if (j+winLength-overlapLength < lengthx)
> wy = hanning(winLength).* x(j:winLength+j-1);
> else
> zpx = [x,zeros(1,part I'm having trouble with)];
> wy = hanning(winLength).* zpx(j:winLength+j-1);
> end
> end
>


This seems a little strange to me but OK....
You want to specify a window of length WinLength and apply it to data "x",
yes?
Actually, the code looks like you want to do a sliding window over the data,
yes?
You have something called overlapLength that's not defined anywhere. Are we
supposed to just figure that out so you don't have to work too hard?
There's not a clue. I'll assume that it's smaller than windowLength just for
fun.
I'll assume that lengthx is >> windowLength and that overlapLength is
something like windowLength/2 or /4.
For lengthx=100, windowlength=32 and overlaplength=8

for j = (1:25:100);
j=1
> if (25< 100)
> wy = hanning(32).* x(1:32);

j=25
> if (49< 100)
> wy = hanning(32).* x(25:56);

j=49>
if (73< 100)
> wy = hanning(32).* x(49:80);

j=73
if (97<100)
> wy = hanning(32).* x(73:104); Looks like trouble here!!!

x(104) isn't defined is it?
j = 97
> if (121< 100)
> else
> zpx = [x,zeros(1,??????)];
> wy = hanning(32).* zpx(97:128);
> end
> end


It looks like the trouble is your test
> if (j+winLength-overlapLength < lengthx)


it might be better
if(winLength+j-1)>lengthx

or something like that....

Fred


Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Padding strings [email protected] VHDL 5 11-22-2007 12:30 PM
Implicit Zero Padding? Gary Spivey Verilog 8 11-03-2006 06:54 PM
zero padding radix - 2 FFT [email protected] DSP 5 05-14-2006 05:28 PM
Zero padding in FFTW Peng Yu DSP 5 03-06-2005 04:21 AM
Zero Padding a DFT quick one DSP 5 02-02-2005 05:34 PM


All times are GMT +1. The time now is 12:45 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved