upsample2 - Upsample without extra overhead zeros

David Valencia October 27, 2010 Coded in Matlab

This is a simple function to replace the one from MATLAB. The problem is that the original function adds extra overhead zeros at the end of the vector, but sometimes it would be desired to get a vector with just zeros BETWEEN the actual samples.

This function is required by several programs related to the DWT transform, which is posted in the following blog post:

% David Valencia
% Posted @
% in:

function [y] = upsample2(x,N)

lx = length(x);
y = 0;

% Put first sample in the first position of the output

y(1) = x(1);

for i=2:lx
    % Create a "chunk" (or piece) of vector, composed
	% with a series of zeros and the next sample from
	% the input
	chunk = [zeros(1,N-1),x(i)];
	% Append the chunk to the current output vector
    y = [y,chunk];


There are no comments yet!

Sorry, you need javascript enabled to post any comments.