How do I take a small array, keyed by a datetime variable which is a subset of a larger array and replace the values in the larger array with the values from the smaller array?
조회 수: 2 (최근 30일)
이전 댓글 표시
What is the best way to take an table which is keyed by a datetime variable and replace the data in a much larger taable (same variables in both) with the data in the smaller table? The smaller table could fall anywhere in the larger table's date range but the smaller table will be made up of contiguous dates.
댓글 수: 0
채택된 답변
Guillaume
2018년 5월 14일
[isinsmall, where] = ismember(bigtable.datevariable, smalltable.datevariable);
bigtable(isinsmall, :) = smalltable(where, :);
Assuming both tables have the same variable names.
댓글 수: 0
추가 답변 (2개)
Ameer Hamza
2018년 5월 14일
If both tables have same variable names, you can insert the small table inside large table much like inserting rows inside the matrix. For example
bigTable = ... % you big table
smallTable = ... % your small table
newBigTable = [bigTable(1:5, :); smallTable; bigTable(5:end, :)];
this will insert small table after 5 rows of the large tables and then insert the remaining large table at the end.
댓글 수: 2
Ameer Hamza
2018년 5월 14일
In that case, refer to @Guillaume's answer. It will overwrite the values in the big table with values in the small table.
Peter Perkins
2018년 5월 14일
The answer might be join, or maybe outerjoin. It might also be synchronize. It's hard to tell from your question.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!