How can I matching data from different matrices
5 views (last 30 days)
Show older comments
Hi!
I have 2 matrices [A], [B], with different dimensions ([A]=4450x10 & [B]=3656x5). The first column in both matrices is the day with numbers 1:365. But some days are missing, not the same days from the two matrices. Also,for each day I have different number of data. For example, in the day 15 in [A] I have 12 lines and in the [B] I have 4 lines. I found the common days:
Common_days = intersect(A(:,1),B(:,1));
Then, I want to create two files (one for each matrix), which will include only the data with the common days.
Extra, I want to plot in the same graph, the data with the same day from [A] & [B]. The columns I want to plot are [A]=2 & 10, [B]=2&5
0 Comments
Accepted Answer
More Answers (1)
Image Analyst
on 20 Mar 2015
Use ismember() to find out what rows Common_days are in. Then just use indexing
[ia, ib] = ismember(.......
subsetA = A(rowsToExtract, :);
I can't remember if rowsToExtract is ia or ib but you'll know which it is after you run it.
See Also
Categories
Find more on Characters and Strings 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!