index out of bounds because size(BP)=[0,0].

3 views (last 30 days)
function [ BPw ] = BPSlidingWindow( BP, n )
m = size(BP,1);
MeanMatrix = zeros(m+n+1, m+2);
MeanMatrix(1:n, :) = 1/n;
Tmp = circshift(MeanMatrix(:), n);
Tmp = reshape(Tmp(1:(end-m-2)), m+n, m+2);
mp = Tmp((n+1):end, 1:(end-2));
Tmp = Tmp./repmat(sum(Tmp, 1), size(Tmp,1), 1);
BPw = [BP(:,1), ( (Tmp')*BP(:,2:end))];
end
Attempted to access BP(:,1); index out of bounds because size(BP)=[0,0].
Error in BPSlidingWindow (line 14) BPw = [BP(:,1), ( (Tmp')*BP(:,2:end))];
Can u help me, Thanks.

Accepted Answer

Jan
Jan on 6 Mar 2012
The input BP is empty. Therefore you cannot process its elements. There is no BP(:,1) vector.
Solution:
function BPw = BPSlidingWindow(BP, n)
if isempty(BP)
BPw = [];
return;
end
m = size(BP,1);
...

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!