How do I change column headers in my table

10 visualizzazioni (ultimi 30 giorni)
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 Commento
Torsten
Torsten il 26 Ago 2025
You overwrite tables 1-27 in your loop and you are left with table 28.

Accedi per commentare.

Risposta accettata

Star Strider
Star Strider il 26 Ago 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}
ans = 6×2 table
Force Storey 1 ________________ ____________________________________________________________________ "Axial Force" 0.25824 -1.0666 0.52455 0.061362 0.83612 -0.57872 "Shear Force" -0.33978 -0.677 0.08896 -0.55037 -1.9187 0.052839 "Bending Moment" -0.68629 -0.77981 0.52746 -0.6832 0.45266 0.13577 "Axial Force" 0.97137 2.5555 0.16246 1.1639 1.7025 -0.40126 "Shear Force" -1.3975 -0.23952 -2.0119 1.1432 -0.26792 2.2068 "Bending Moment" -1.4253 0.063041 -2.4109 0.26882 -0.90365 0.049716
ans = 6×2 table
Force Storey 2 ________________ _________________________________________________________________________ "Axial Force" -1.1477 0.6543 -0.14317 -0.039486 1.4339 -1.264 "Shear Force" -0.42278 -0.054125 -0.022768 0.5618 -0.078847 0.91655 "Bending Moment" -2.3065 -0.2194 -0.25508 1.2181 -0.1286 -1.2847 "Axial Force" -2.0327 1.8675 -2.0148 0.52304 0.49065 0.072621 "Shear Force" -0.29637 0.082269 1.2084 0.72773 2.039 -1.5388 "Bending Moment" -0.24284 -2.3689 -0.67396 0.36504 -0.58589 0.82584
ans = 6×2 table
Force Storey 3 ________________ _________________________________________________________________________ "Axial Force" 0.45866 -0.43073 0.18425 -0.22845 0.81357 -1.0366 "Shear Force" 0.39192 -0.052734 0.6977 0.09103 -0.42306 -1.1206 "Bending Moment" 0.061773 -0.91316 0.651 0.23485 -0.11815 -1.2856 "Axial Force" 2.1351 0.69848 -0.19996 -0.77539 2.8288 0.31379 "Shear Force" 1.9178 -1.041 0.0087346 -1.2634 0.10913 -0.33258 "Bending Moment" 0.31495 -1.8692 0.97796 -0.82828 -0.8282 -0.29363
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 Commenti
Scott Banks
Scott Banks il 26 Ago 2025
Thank you once again, Star Strider

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Dates and Time in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by