Adding table headers when headers change each loop

8 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Call 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