Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

eliminating rows in a file (rookie question)

1 vue (au cours des 30 derniers jours)
Peter
Peter le 16 Fév 2014
Clôturé : MATLAB Answer Bot le 20 Août 2021
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!)

Réponses (2)

Wayne King
Wayne King le 16 Fév 2014
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 le 16 Fév 2014
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,:)

Cette question est clôturée.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by