Info

この質問は閉じられています。 編集または回答するには再度開いてください。

eliminating rows in a file (rookie question)

1 回表示 (過去 30 日間)
Peter
Peter 2014 年 2 月 16 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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!)

回答 (2 件)

Wayne King
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,:);

Image Analyst
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,:)

この質問は閉じられています。

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by