# How to extract data from one column using the data from the two other columns

2 visualizaciones (últimos 30 días)
Claire el 3 de Dic. de 2020
Comentada: dpb el 4 de Dic. de 2020
I have data with 3 columns, A B and C. A contains serial dates, and B contains data that corresponds to the serial date in column A. in column C, I have a much shorter column of select serial dates that I have to have the correspoding data for from column B. Is there a way to use column C to search column B and extract only the data that corresponds to the dates in column C?
Column A is all of the serial dates, column B is the soil moisture retrieved on that serial date in column A, and column C are the select serial dates that I need column B values for; so I want to be able to make an array of the column B values that correspond to the selected column C serial dates.
I have having problems putting this question into words properly, so if I was unclear i apologize and I can try to elaborate. Thank you!
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

dpb el 3 de Dic. de 2020
res=B(ismember(A,C));
##### 2 comentariosMostrar NingunoOcultar Ninguno
Claire el 4 de Dic. de 2020
Editada: Claire el 4 de Dic. de 2020
Hello, thanks for your help! this worked, but it returned far less values than i expected
i think it is only when the rows of A and C are adjacent and equal each other. in column C, i am missing a lot of datetimes that are present in A, so the datetimes in C are not organized or aligned with column A. sorry for not being clear about that!
is it possible to do this same process, but with any values of C that match those in A, regardless of whether or not the same dates are in the same row?
dpb el 4 de Dic. de 2020
ismember is position independent.
The problem is more likely one of floating point precision -- try ismembertol

Iniciar sesión para comentar.

### Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by