MATLAB Answers

checking the existence of timetable and merge

조회 수: 5(최근 30일)
Sehoon Chang
Sehoon Chang 3 Sep 2020
편집: Jon 3 Sep 2020
Hi
within a folder i have diverse excel data type, which are imported and then converted to timetable within MATLAB.
(eg. timetable_csv, timetable_xls,timetable_xlsb, etc.)
It is possible that all of the timetables of various data type exist or only a few types exist depending on the content of the folder.
However, the name of all timetable do exist.
At the end i wish to merge all the existing timetable into one using the code 'outerjoin'.
How may i find out which of the timetables do exist and can be merged with other existing timetables?
I tried to merge each timetables like it is show below. However, the processing stops due to the timetable that do not exist (empty).
timetable = outerjoin(timetable_xltx,outerjoin(timetable_xltm,outerjoin(timetable_xlsx,outerjoin(timetable_xlsm,outerjoin(timetable_xlsb,outerjoin(timetable_csv,timetable_xls))))))

답변(1개)

Jon
Jon 3 Sep 2020
편집: Jon 3 Sep 2020
If it is a question of whether the variables have been created at all, you can check whether they exist using the exist MATLAB command, e.g. and branch accordingly
if exist('timetable_xltm') ...
If the variables always exist, but sometimes there is nothing in them, that is they are empty, you can test for that using the MATLAB command isempty, e.g. and branch accordingly
if isempty(timetable_xltm) ...

Community Treasure Hunt

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

Start Hunting!

Translated by