フィルターのクリア

Call the most recent timetable value

2 ビュー (過去 30 日間)
Poison Idea fan
Poison Idea fan 2021 年 3 月 3 日
回答済み: Poison Idea fan 2021 年 3 月 3 日
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.

採用された回答

Poison Idea fan
Poison Idea fan 2021 年 3 月 3 日
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 件)

カテゴリ

Help Center および File ExchangeData Preprocessing についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by