How to add header row to cell array?

209 vues (au cours des 30 derniers jours)
Mariagrazia Ambrosino
Mariagrazia Ambrosino le 12 Mai 2022
Hi everyone.
I have a cell array like this:
I would like to add a header row with the following fields: ['Type' 'Latency' 'Description'].
I've tried the reshape function but can't get good results. Can anyone help me please?

Réponses (1)

dpb
dpb le 12 Mai 2022
A cell array doesn't have the facility for headers, per se; if you add to it you've effectively created more data -- and when you go to use the data, then you have to remove or not reference that row to operate on the data alone. This is a lot of effort.
I'd suggest to use a table instead; you get the header effectively for free from the column/variable names.
tC=cell2table(C,'VariableNames',{'Type','Latency','Description'});
  5 commentaires
dpb
dpb le 12 Mai 2022
See writetable It'll do whatever you need...
Mariagrazia Ambrosino
Mariagrazia Ambrosino le 12 Mai 2022
thanks you !!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Characters and Strings 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