How do I change column headers in my table
    7 views (last 30 days)
  
       Show older comments
    
    Scott Banks
 on 26 Aug 2025
  
    
    
    
    
    Commented: Star Strider
      
      
 on 26 Aug 2025
            I have some data that I am displaying in my script and have outputted it in 28 different tables. My script is quite long so I am just posting a screenshot for now.

Where is says var 2 I want to change to the storey number. So for table 1 I want storey 1, for table 2, storey 2 etc...
If you can see for the main output i am running a loop and using the matrix called "Int_force". I also have made the row headers as [Axial Force, Shear Force, Bending Moment. Thus, I am hoping someone can help me so that I can change the column headers to my desired wish? I am not sure how I would change the loop to accomplish this.
Many thanks,
Scott
1 Comment
Accepted Answer
  Star Strider
      
      
 on 26 Aug 2025
        If your immediate problem is naming the variables, perhaps --
Int_force = randn(6,6,28);
Force = repmat(["Axial Force";"Shear Force";"Bending Moment"],2,1);
for ii = 1:28
    T{:,ii} = table(Force,Int_force(:,:,ii), VariableNames=["Force","Storey "+ii]);
end
T{1:3}
Note that 'T' was being overwritten in every iteration of the loop, so I created a cell array of them.  
Make appropriate changes to get the result you want.  
.
4 Comments
More Answers (0)
See Also
Categories
				Find more on Dates and Time in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

