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

1 vue (au cours des 30 derniers jours)
Dmitry
Dmitry le 6 Mar 2012
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.

Réponse acceptée

Jan
Jan le 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);
...
  2 commentaires
Dmitry
Dmitry le 6 Mar 2012
thx, i will try
Dmitry
Dmitry le 6 Mar 2012
thx. it is working

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by