suppose that i want to create following data matrix
for creating such type of matrix, i have already written code
function [ x ]=create_matrix1(b,l)
n = length(b);
m = n-l+1;
x = zeros(m,l);
for i=1:m
x(i,:)=b(i:i+l-1);
end;
end
but when we have a large data, then creating of such matrix became big problem, for instance if we generate data from matlab like this
load ampoutput2.mat
[m n]=size(y)
m =
500000
n =
1
if p=2000
then of course it will crush, computer will stop working, is there any iterated version which i can do for creating this matrix?thanks very much
答案 0 :(得分:1)
我认为你想要的是hankel
功能。但您可能不希望显式构造矩阵,具体取决于您要对其执行的操作。您可以将这种类型的矩阵与O(N log N)时间内的向量相乘,并调用flip
并使用FFT。
答案 1 :(得分:1)
可以通过这种方式有效地创建矩阵:
create_matrix2 = @(b, l) b(bsxfun(@plus, (1 : l), (0 : numel(b)-l)'));