How to replace portion of data set with another?
9 views (last 30 days)
Assume you have two 20x20 data sets (just an example). The first column of data contains the time the data was recorded (1,2,3,4,5) and the rest of the data are the values that correspond with that time. What I need to do is take the data from 5 to 10 seconds of one data set (assume this data set is a) and replace the 5 to 10 seconds of the second data set (across all columns, this data set is b), essentially giving me a merged data set.
I think that using indexing might be the best choice (and assuming our data sets are a and b), so something like
Those would give me the two locations of the data, but how would I remove the data from that data set and replace the data in the other?
Guillaume on 12 Jul 2017
Assuming that both matrices have the same number of rows for your 5 to 10 range and that they're in the same order:
b(b(:, 1) >= 5 & b(:, 1) <= 10, 2:end) = a(a(:, 1) >= 5 & a(:, 1) <= 10, 2:end)
is one way of doing it.
More Answers (1)
dbmn on 12 Jul 2017
One way to solve this would be by logical indexing (assuming both datasets have the same time increment)
% Example data
% Find time < 5s
index = a(1,:)<5
% Merge Data
b(:, index) = a(:,index);