Repeating string variables to form a new string variable

Hello to all
I`m estimating a VAR and I want to export some results in an Excel sheet. I want to add column names direct from matlab and I did this already. However, the way my VAR is estimated, I need that my column name variable to be of size (1,nvar^2+1), where nvar is the number of variables in the system.
I created a variable called var_names = ['var1', 'var2','var3']; which contains the labels for the variables names.
In this case, where I have 3 variables, I want:
col_names = ['Horizon' var_names var_names var_names];
My question is: How to automatize this repetition? I want this to be a function of nvar so when I estimate a different model with different number of variables I do not have to change this code, so I would have something like:
col_names = ['Horizon' var_names times nvar];
Thank you all in advance.

Questa domanda è chiusa.

Richiesto:

il 13 Lug 2016

Chiuso:

il 20 Ago 2021

Community Treasure Hunt

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

Start Hunting!

Translated by