How to fix iteration of one positive integer in an equation to update automatically in next index?

3 vues (au cours des 30 derniers jours)
Following is the code I am using:
Batt_Power = 45.5; % kW
Power = 108*1000; % kW
Journery_Time_Hrs = 0.8; %hrs
Battery_Capacity = 87; % Unit kWh Positive Intiger
Energy_Used = cumsum(Batt_Power * ((EnergyF)/3.6/1000000))/ (Power/1000); % Cumulative Energy
Energy_Regen = FC_Charging * Journery_Time_Hrs;
% Size of Arrays
EnergyF = 2241x1;
Energy_Used = 1x22401; % Unit kWh Cumulative Data
Energy_Regen = 1x22401; % Unit kWh Cumulative Data
I am using this equation to find battery state of charge.
Soc = Battery_Capacity - Energy_Used + Energy_Regen;
% size of Soc = 1000*1
This is suppose to give me battery state of charge. However, it does not provide correct answer.
I know why but I don't know how to fix it.
The problem originates from Battery_Capacity.
Expected Correct Result:
This is the correct result I shall get if I use Soc equation correctly. The Battery Capacity must automaticaly update it self in next index of Battery_Capacity till end of the array.
87 - 0.5 + 0.3 = 86.2
86.2 - 0.7 + 0.4 = 85.9
85.9 - 1.4 + 0.5 = 85
Wrong Result From Code:
But, I am getting this kind of result, Battery_Capacity is always 87 till the end of array.
87 - 0.5 + 0.3 = 86.8
87 - 0.7 + 0.4 = 86.7
87 - 1.4 + 0.5 = 86.1
Can any one please sugguest how can I fix this.
Thanks
  7 commentaires
KSSV
KSSV le 12 Déc 2018
I think after the formula for soc you need to update :
Battery_Capacity = soc ;
Shahab Khan
Shahab Khan le 12 Déc 2018
Mark Sherstan all three vectors uploaded. Size also updated in code.

Connectez-vous pour commenter.

Réponse acceptée

Cris LaPierre
Cris LaPierre le 12 Déc 2018
Modifié(e) : Cris LaPierre le 12 Déc 2018
You are not updating the value of Battery_Capacity (you know that). How are you calculating SOC? All at once or inside a for loop? I think it would have to be in a loop to work because values on Soc(n+1) depend on the calculation performed in Soc(n). Taking KSSV's suggestion from above:
for idx = 1:length(Energy_Used)
...
Soc(idx) = Battery_Capacity - Energy_Used(idx) + Energy_Regen(idx);
Battery_Capacity = Soc(idx);
end
  3 commentaires
Cris LaPierre
Cris LaPierre le 12 Déc 2018
Using the variables provided in your mat file, the difference between these two approaches for calculating Soc is <1e-8
Shahab Khan
Shahab Khan le 12 Déc 2018
Cris LaPierre Thank you for your answers. I followed both of your methods and both works fine for me now. I just had to re arrange my arrays and got my desired results.
Thank you for your time.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Spline Postprocessing dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by