left outerjoin without changing initial order in the output
Show older comments
i want to make outerjoin in such way to have output C keeping the same order as the key variable, precisely my key variable is dates when i apply outerjoin i see that the output C is sorted ascending way because the dates are detected as numbers example
dates=[05012000 02032000 31012000 15092007]';
ret1=[100 55 66 23]';
tab1=table(dates,ret1);
clear dates
%========
dates=[05012000 08012000 31122000]';
ret2=[2 8 7]';
tab2=table(dates,ret2);
%====
[C] = outerjoin(tab1,tab2,'Type','left');
%result
dates_tab1 dates_tab2
*2032000* 55 NaN NaN
5012000 100 5012000 2
15092007 23 NaN NaN
*31012000* 66 NaN NaN
you can see that in the output we have 31012000 in the bottom wich is not convenient cause i want to have the same sorting dates us in my initial vector dates such that
dates_tab1 dates_tab2
5012000 100 5012000 2
*31012000* 66 NaN NaN
*2032000* 55 NaN NaN
15092007 23 NaN NaN
Accepted Answer
More Answers (0)
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!