From: William on
This is a question about combining text strings and numerical values in the same matrix. I would like to create a matrix of numerical data, with row headers. I've been trying to preallocate the matrix, and am running into difficulties with defining the right type of structure in the right cell.

This is my current code:

LagOutput=zeros(7,5);
LagOutput{:,1} = {'adfstat';'pval';'critval';'armaq';'armapval';'archq';'archpval'};
for n = 1:5
%(calculate values to be input)%
LagOutput(:,n+1) = [adfstat;pval;critval;armaq;armapval;archq;archpval];
end

Any advice on how I should preallocate the matrix, and how I should define things? And would it be easier to define a column of headers separately and concatenate?
From: Darren Rowland on
To save yourself future misery, if you only want a single header row just define the vector of column headers separately to the numerical matrix. This will produce cleaner and more readable code too, allowing you to give more meaningful names to the arrays.

Hth
Darren