Unique dates and data, supplying values to all repeated dates in a matrix after indexing.
2 views (last 30 days)
Show older comments
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 Comment
Mohammad Sami
on 24 Jan 2020
Edited: Mohammad Sami
on 24 Jan 2020
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
Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!