Kritika
Kritika

Reputation: 65

How to divide a vector into frames in MATLAB?

I'am building a voice morphing system using MATLAB and I need to divide the source and target, training and test samples into frames of 128 samples so that I can then apply DWT on each of the frame. So please guide me how to divide the vector into frames?

Upvotes: 3

Views: 1435

Answers (2)

learnvst
learnvst

Reputation: 16195

An alternative to using reshape would be to use buffer if you have the signal processing toolbox available. Simply . . .

y = buffer(x,128)

.. in your instance. The buffer command will also add trailing zeros to the final frame if the number of elements in your original signal (x) is not an integer multiple of 128.

Upvotes: 0

Jason R
Jason R

Reputation: 11696

You can change a vector into a matrix of equally-sized columns/rows (i.e. frames) using the reshape function:

x = rand(128 * 100, 1);
X = reshape(x, 128, 100);
% X is a 128-by-100 matrix; the i-th column of 128 elements 
% is addressed by X(:,i)

Upvotes: 6

Related Questions