Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

eliminating rows in a file (rookie question)

1 visualización (últimos 30 días)
Peter
Peter el 16 de Feb. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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!)

Respuestas (2)

Wayne King
Wayne King el 16 de Feb. de 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 el 16 de Feb. de 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,:)

La pregunta está cerrada.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by