# Call the most recent timetable value

4 visualizzazioni (ultimi 30 giorni)
Poison Idea fan il 3 Mar 2021
Risposto: Poison Idea fan il 3 Mar 2021
I have 2 timetables. In order to make a calculation on the data in the first table, I need to call the most recent values of the second table.
for k = 1:numel(rawData_Timetable)
value(n,:) = reflectivity_Timetable.('Reflectivity')(most_recent) .* rawDataTT.('Spectra')(n,:);
end
How could I compare the times in the rawData_Timetable and find the most recent row of the reflectivity_Timetable for the calculation?
Initially I thought to loop through the reflectivity_Timetable and concatenate to a new timetable, but I feel there must be asolution that doesn't involve creating a nested loop through the rawData_Timetable and reflectivity_Timetable.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Poison Idea fan il 3 Mar 2021
So, I answered my own question. But, maybe someone has a better solution!
I take the difference between the times of the measurements and remove all of the positive durations. I do this because you will always need the previous reflectivity measurement. Then i find the minimum of the absolute value of the duration and save the index in a new array.
x = refTT.('Time'); % this is unnecessary but I initialize arrays with the datetimes
y = [rawDataTT.('Var1')];
for n = 1:height(refTT) % take the time diff for each rawDataTT row
time_diff(n,:) = x(n,1)-y(:,1);
end
time_diff(time_diff > 0) = NaN; % remove positive durations
[~,I] = min(abs(time_diff(:,:)),[],'omitnan'); % find the minimum backwards duration
for k = 1:height(rawDataTT) % do the calculation with the index in I
extinction(k,:) = refTT.('Reflectivity')(I(k),:) + ext_bath .*...
(rawDataTT.('Spectra')(k,:);
end
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Logical in Help Center e File Exchange

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by