MATLAB: How to display matrix with column labels only? (i.e. no row labels)

columnslabelling

Hi there
I have a 1300×23 matrix and I want to label CERTAIN columns only (and not rows as well). I'm facing 2 challenges: 1. how to do it? 2. how to do it taking into account that I don't want to label all columns (and, those columns that I want to label aren't consecutive, so I can't use x:y) and I don't want to write the code for every single column that I want to label (which I have the hunch that implies writing a for loop in the end)
Many thanks in advance

Best Answer

Here is one way:
x = magic(5);
header = {'Col 1','','Col 3','',''};
xForDisplay = [header; num2cell(x)];
disp(xForDisplay)
Related Question