Matching columns of arrays to fill up a corresponding empty column
5 views (last 30 days)
While determining the battery voltage values from battery state of charge values, I'm encountering the following issue:
I have one array of 10.001 rows and 2 colums (10.001x2), giving percentage in steps of 0.01 percent
and one array of 604.800 rows and 2 columns (604.800x2), giving values of the voltage.
The first array describes the relation between state of charge and the voltage potential in the battery. The left column goes from 0 to 100 percent, in steps of 0.01 percent, and the right column gives corresponding voltage values that range from 2.8015 V to 4.1458 V.
My second array, in the first column, has 604,800 rows of percentage values (one week of state of charge values). The left column starts at 90%, goes up and down a few times, ending up close to 90% again. The second column of this array is empty.
How can I fill up the second column of the second array ([empty] values), with the values that correspond to those percentages from the first array?
Thanks in advance.
Voss on 13 May 2022
It looks like SoC_internal_new is not values between 0 and 100 percent but between 0 and 1:
And SOC is in percent:
So one of them must be converted in order to compare them. I'll convert SoC_internal_new to percent and construct the first array described in the question:
input_data = [100*SoC_internal_new(:) OCV_new(:)]
Then the second array described in the question has SOC in the first column and interpolated values in the second column:
output_data = [SOC(:) interp1(input_data(:,1),input_data(:,2),SOC)]
% plot both arrays
% SOC (i.e., output_data(:,1)) is unsorted (i.e.,
% it goes up and down, as described in the question),
% so sort output_data according to the values of
% output_data(:,1), for plotting
[~,idx] = sort(output_data(:,1));