Create matrix from a 1xk vatrix without loop for FFT?

I am looking to create a matrix arranged differently from the original for easy FFT using block processing.
Assuming the input array is A=[1,2,3,4,5,6,7,8,9,...k-1]
I want to arrange it into blocks of 4 vertically with a 50% overlap. The result should look like:
IDX = [1 3 5 7; 2 4 6 8; 3 5 7 9; 4 6 8 10]
So then I could do fft(IDX) to get the appropriate FFT for the blocks.
I have looked into bxsfun function, but it allows me to create the following
IDX = [1 2 3 4; 2 3 4 5; 3 4 5 6; 4 5 6 7]
Thanks.

回答(1 个)

Umair - try using arrayfun to create the columns of your matrix given the first row inputs of 1,3,5,7,...,k-4 where k is odd. For example
k = 11;
IDX = cell2mat(arrayfun(@(x)(x:x+3)',1:2:k-4,'UniformOutput',false));
returns
IDX =
1 3 5 7
2 4 6 8
3 5 7 9
4 6 8 10
In the above code we supply a function, @(x)(x:x+3)' which for every integer input, creates a column vector of values as [x x+1 x+2 x+3]' which corresponds to one column of our IDX matrix. The second input to arrayfun is our data which corresponds to the first row of our IDX matrix - so all odd numbers. We then convert the output from a cell array to a matrix (via cell2mat) and we are done.

提问:

2014-11-12

回答:

2014-11-13

Community Treasure Hunt

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

Start Hunting!

Translated by