left outerjoin without changing initial order in the output
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!