Unique dates and data, supplying values to all repeated dates in a matrix after indexing.

2 次查看(过去 30 天)
Hi. I have a matrix (A = 70 x 2) with unique date and temperature. Then I have an array of dates (B = 500 x 1) with several repetition that exactly match with the unique dates in the matrix (A). How do I index the repeated dates in B with A? From this, I'd like to make a new column in B containing the temperature from A (even if they're repeated)? I tried intersect, find, fun, etc even using for loops, but I can't seem to find the right function or workaround to do this. Any help would be appreciated.
  1 个评论
Mohammad Sami
Mohammad Sami 2020-1-24
编辑:Mohammad Sami 2020-1-24
use ismember.
[logical_date_is_in_a, index_of_date_in_a] = ismember(date_col_in_b,date_col_in_a);
logical_date_is_in_a true if the date in B exist in A
index_of_date_in_a this would contain 0 if the date in B does not exist in A

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by