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)
Afficher commentaires plus anciens
Shahab Khan
le 12 Déc 2018
Commenté : Shahab Khan
le 12 Déc 2018
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
le 12 Déc 2018
I think after the formula for soc you need to update :
Battery_Capacity = soc ;
Réponse acceptée
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
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spline Postprocessing 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!