필터 지우기
필터 지우기

merging multiple timetable using for loop

조회 수: 4 (최근 30일)
Sehoon Chang
Sehoon Chang 2020년 9월 8일
댓글: Sindar 2020년 9월 10일
Hi all,
i am trying to merge multiple timetables using the code 'outerjoin' and 'for loop'.
Amongst many timetables that are imported from a folder, there are (may exist) empty timetables inbetween.
The existence of each timetable data types are checked and then organized as an array to merge them using 'for loop'.
if exist ('timetable_csv') % checking whether timetable data exist
timetable_{1} = timetable_csv
end
Below is the 'for loop' iteration, which should at the end 1) disregard non-existing timetables and 2) merge all existing timetables.
As i ran this code, error message came stating "Error using tabular/outerjoint. A and B must be tables"
numtimetable = length(timetable_)
for h = 1:numtimetable
timetable = timetable_{h}
for hh = 2:numtimetable
timetable = outerjoin(timetable,timetable_{hh})
end
end
Thus i tried to change the variable 'timetable_{ }' cell array to timetable, as 'timetable' was ok.
numtimetable = length(timetable_)
for h = 1:numtimetable
timetable = timetable_{h}
for hh = 2:numtimetable
table_c2t{hh} = cell2table(timetable_{hh})
timetable_t2tt{hh} = table2timetable(table_c2t_{hh})
timetable = outerjoin(timetable,timetable_{hh})
end
end
However, another message appeared stating, "Error using cell2table. Cell must be 2-D cell array".
I would appreciate if you could advise me how to restructure the code so that i may merge multiple titmetable using the example presented above.
Of course, merging them using other possible coding is welcome as well.
thanks.
  댓글 수: 3
Sehoon Chang
Sehoon Chang 2020년 9월 9일
i am defining all the tables (ex. timetable_csv) in "timetable_".
Sindar
Sindar 2020년 9월 10일
You define timetable_ as timetable_csv. Where/how do you define timetable_csv?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by