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
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 Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!