Info
此问题已关闭。 请重新打开它进行编辑或回答。
eliminating rows in a file (rookie question)
2 次查看(过去 30 天)
显示 更早的评论
I have the following data: one variable 'markers' containing two columns(first is sample number, second is time-stamp):
123 2.334
645 3.445
1234 4.246
2450 5.332
2901 6.092
3287 6.345
3991 7.764
and so forth(goes down to 170 rows)
I have another called 'corrected' which contains only the first column of the previous variable minus certain rows(erroneous data which another piece of code was used to clear up the wrong samples):
123
645
1234
2901
3991
How can I use the 'corrected' set of numbers to eliminate the rows in the 'markers' variable so I get:
123 2.334
645 3.445
1234 4.246
2901 6.092
3991 7.764
I am new to matlab, so please be nice!(also, THANK YOU!)
0 个评论
回答(2 个)
Wayne King
2014-2-16
Using your example
A = [123 2.334
645 3.445
1234 4.246
2450 5.332
2901 6.092
3287 6.345
3991 7.764];
B = [ 123
645
1234
2901
3991];
[c1,ia,iab] = intersect(A(:,1),B,'rows');
newdata = A(ia,:);
0 个评论
Image Analyst
2014-2-16
Try this:
markers = [...
123 2.334
645 3.445
1234 4.246
2450 5.332
2901 6.092
3287 6.345
3991 7.764]
corrected = [
123
645
1234
2901
3991]
% Now do the extraction:
rowsToTake = ismember(markers(:, 1), corrected)
correctedMarkers = markers(rowsToTake,:)
0 个评论
此问题已关闭。
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!