Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

eliminating rows in a file (rookie question)

1 visualizzazione (ultimi 30 giorni)
Peter
Peter il 16 Feb 2014
Chiuso: MATLAB Answer Bot il 20 Ago 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!)

Risposte (2)

Wayne King
Wayne King il 16 Feb 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 il 16 Feb 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,:)

Questa domanda è chiusa.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by