To make it easier for people to help, you could try to use the same words in your description of what you are trying to do as in the code. Also make sure that the code that you post can run, so if it needs any data, then either provide it, or include code that generates random data. That way the people who want to help don’t have to guess.
For example, here’s how to generate some data:
X1 = rand(5) # A random vector
Companion = rand(5,5) # A random matrix
Now, what I think you want to do is add new vectors to the end of a list. This is done with the push!
function in Julia.
maxiter = 46;
Xt = [X1] # A list of vectors, containing just one vector to start with.
for i = 1:maxiter
push!(Xt, Companion*last(Xt))
end
After running this code, the list Xt
will contain 47 vectors.
Another way of doing it would be to store the vectors side-by-side in a matrix. (Let’s call it M
, to make it different from Xt
.)
M = zeros(length(X1), maxiter+1) # Create the matrix filled with zeros to start with
M[:,1] = X1 # Set the first column of the matrix
for i=1:maxiter
M[:,i+1] = Companion*M[:,i]
end