Adding table headers when headers change each loop
조회 수: 7 (최근 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
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 Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!