Effacer les filtres
Effacer les filtres

How can I display matrix with column labels only? (i.e. no row labels)

6 vues (au cours des 30 derniers jours)
Bianca Elena Ivanof
Bianca Elena Ivanof le 20 Mar 2016
Commenté : the cyclist le 20 Mar 2016
Hi there
I have a 1300x23 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

Réponse acceptée

the cyclist
the cyclist le 20 Mar 2016
Here is one way:
x = magic(5);
header = {'Col 1','','Col 3','',''};
xForDisplay = [header; num2cell(x)];
disp(xForDisplay)
  5 commentaires
Bianca Elena Ivanof
Bianca Elena Ivanof le 20 Mar 2016
yep, now everything's clear. num2cell sounded familiar but when i read about cell arrays i didn't quite understand what the function was doing in practice - everything's clear to me now.
thank you
the cyclist
the cyclist le 20 Mar 2016
You're welcome. The best form of thanks is to upvote and/or accept an answer, which rewards the contributor and can point future users to useful answers.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by