Adding table headers when headers change each loop

7 ビュー (過去 30 日間)
Natasha Bryan
Natasha Bryan 2021 年 8 月 9 日
コメント済み: Peter Perkins 2021 年 8 月 9 日
Hello, I have a number of datasets that I am reading in that have varying numbers of columns (i.e. some columns are missing from some datasets). I'm attempting to process the data and then at the end of each loop adding the data to a table. My problem is that I cannot manually set the variable names of the table to {'x', 'y', 'z'} as z may not always be present. I tried using:
Headers = cell2table(originaldata.varnames);
Headers(:,contains(Headers.Properties.VariableNames, 'x'));
to create a variable 'Headers' that would change size with each loop and I could set as variable names to my final table. However using below code isn't working.
finaldata.Properties.VariableNames = {'Headers'};
%or
finaldata.Properties.VariableNames = Headers;
I do not want to have to specificy the exact variable names as they change each loop.
Is there someway to do this?
Many thanks,
Natasha
  1 件のコメント
Peter Perkins
Peter Perkins 2021 年 8 月 9 日
Natash, according to your description, this
finaldata.Properties.VariableNames = Headers;
should work. You need to post more information, such as what is in finaldate and Headers, and what error you are getting.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by