Good afternoon everyone,
I would like some advice, I have a table that I have converted into a cell array to do do some rearranging of the data to help in further calculations. What I would like to do is convert a copy of this cell array into a table and attach pre-existing headers back, including a new one, just to keep track of the variable names. I have tried creating tables within the cell array loops and assigning the headers to it, but it is only applied to the primary table because of the way the code works in reconfiguring the data.
What the code does is rearrange the table content into a new cell array, so that each slope angle how has a 1x3 cell (H,M,L) with the parameters (X,Y displacements etc) contained within. The two attachments are an image of the primary data table with the 1x3 cell within represent 'High, Med, Low' levels (file too big to attach). and the second is a light versions of the output data from the code, so you get an idea (First layer = Slope angles, 2 seconds layer = H,M,L and 3rd = Parameters)
Is there a way to re-arrange the table while maintaining the header names? Or my preference, attach the header names back at the end?
Many thanks
(Note: There is an empty cell for the 3rd nested cell of each)
New_cell = cell(1,5);
SA = [27,45,63,76,90]
WL = {'High','Med','Low'};
for a = 1:size(C_SMC,1)
Slope{a} = sprintf('Slope_%d',SA(a));
for b = 2:size(C_SMC,2)
for c = 1:size(C_SMC{a,b},1)
New_cell{a}{c}{1,b} = C_SMC{a,b}{c,1};
end
end
end
Pre_calc_tab = cell2table(New_cell,'VariableNames',Slope)
3 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/500629-cell2table-header-transfers#comment_786773
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/500629-cell2table-header-transfers#comment_786773
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/500629-cell2table-header-transfers#comment_787006
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/500629-cell2table-header-transfers#comment_787006
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/500629-cell2table-header-transfers#comment_787014
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/500629-cell2table-header-transfers#comment_787014
Sign in to comment.