I've got the following problem: Every time I run the code below, I get the message: "Array indices must be positive integers or logical values." Each variable is a column vectore (size 300x1 each). I'm not able to figure out where the bug could be since the index variables are never negative (second and third if-clause).
Could anybody help me out? Thank you so much!
Amount = zeros(size(Yield));
Current = zeros(size(Yield));
Current(1,1) = 2000;
M = [Prob1,Prob2,Prob3];
ProbMax = max(M,[],2);
N = [Prob1,Prob2,Prob3];
ProbMin = min(N,[],2);
P = [Probyie1,Probyie2,Probyie3];
ProbyieMax = min(P,[],2);
for i=1:length(Yield)
if ismember(ProbMax(i),Prob1(i)) & ...
ProbMax(i)<0.9 & ProbMin(i)>0 & ...
(0.45 <= ProbMax(i)) & (ProbMax(i) <= 0.75) & ...
Current(idx)>0 & ...
ProbMax>ProbyieMax
idx = floor((i-1)/9)*9+1;
if mod(i,9)==1
Current(idx) = Amount(idx-9:idx-1) + Current(idx-9);
end
Amount(i)=(Current(idx)*0.1*(Prob1(i)-((1-Prob1(i))/(Yield(i)-1))));
else
idx = floor((i-1)/9)*9+1;
if mod(i,9)==1
Current(idx) = Amount(idx-9:idx-1) + Current(idx-9);
end
Amount(i)=0;
end
end
Aucun commentaire:
Enregistrer un commentaire