% Simple algorithm to estimate R0 of the battery based on Gregory % Plett book Battery management systems: volume II clear all; clc; %% Load data to analyze load("Time_test_val.mat"); load("Vbat_test_val.mat"); load("Ibat_test_val.mat"); % Here is the plot of the current and voltage figure(); plot(Time_test_val/3600, Ibat_test_val); title('Current during the test'); grid on; xlabel('Time(hours)'); ylabel('Current(A)'); figure(); plot(Time_test_val/3600, Vbat_test_val); title('Voltage during the test'); grid on; xlabel('Time(hours)'); ylabel('Voltage(v)'); %% Initialization of the real value of R0 R0 = 5e-3; % This is the real value of R0 obtained from the ident. process R0_vect = R0*ones(1, length(Vbat_test_val)); %% Estimation of R0 without any filter % You have to define a threshold for the calculation threshold = 5; for k=2:length(Vbat_test_val) num = Vbat_test_val(k)-Vbat_test_val(k-1); den = Ibat_test_val(k-1)-Ibat_test_val(k); R0_hat(k) = abs(num/den); if (abs(den)