Index exceeds the number of array elements (1).
Afficher commentaires plus anciens
Please i need help !
i'm trying to use the extended kalman filter to estimate Li-ion battery SOC.
this is my code :
%ocv(soc) curve fitting equation
%Voc=M0 + M1*xtrue + M2*xtrue^2+ M3*xtrue^3 + M4*xtrue^4 + M5*xtrue^5 - R*i + sigmaV;
%xtrue the true value of SOC
%xhat the estimated value of SOC
%initialization
xtrue=100;
xhat=0;
sigmaX=100; %kalman error covariance
xstore=zeros(length(xtrue),maxIter);
xstore(:,1)=xtrue;
xhatstore=zeros(length(xhat),maxIter);
sigmaXstore=zeros(length(xhat)^2,maxIter);
for i=1:maxIter
%state equation
xhat(i+1)=xhat(i)-(eff*deltat/Cn)*I(i) +w;
yhat=Voc(i)-R*I(i)+v;
C=M0 + M1 + 2*M2*xtrue+ 3*M3*xtrue^2 + 4*M4*xtrue^3 + 4*M5*xtrue^4 - R*i + sigmaV;
sigmaX=A*sigmaX*A'+sigmaW;
sigmaY=C*sigmaX*C'+sigmaV;
L=sigmaX*C'/sigmaY;
xhat = xtrue +L.*(ytrue-yhat);
%[Store infromation for evaluation/plotting purposes]
xstore(1:17,k+1)= xtrue(:);
xhatstore(1:17,k)=xhat(:);
sigmaXstore(:,k)=sigmaX(:);
end
%code plot
figure(1);
plot(1:maxIter,xstore(1:maxIter)','k-',1:maxIter,xhatstore','b--');grid;
legend('true','estimate');
title('Kalman filter in action');
xlabel('iteration/time'); ylabel('soc');
and i'm guetting this error everytime:
Index exceeds the number of array elements (1).
Error in anothertry22 (line 33)
yhat=Voc(i)-R*I(i)+v;
i verified all the values but don't know how to solve it !
any suggestions please ?!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Estimators dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!