Adding table headers when headers change each loop

7 vues (au cours des 30 derniers jours)
Natasha Bryan
Natasha Bryan le 9 Août 2021
Commenté : Peter Perkins le 9 Août 2021
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 commentaire
Peter Perkins
Peter Perkins le 9 Août 2021
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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by