How can i save a vector with a variable length ?

Hello, I have vector (ind), used in a while loop and whose length is changing in every loop. I need to save (in a table or a mtrix-if it's possible)the value of this vector in each iteration and ofcourse before it change. Thanks you,

 Akzeptierte Antwort

Thorsten
Thorsten am 9 Jan. 2013

0 Stimmen

Use a cell V to store the vectors
for i = 1:N
vec_of_variable_length = ...
V{i} = vec_of_variable_length;
end

Weitere Antworten (1)

Jan
Jan am 9 Jan. 2013

0 Stimmen

You cannot store vectors of different length in a matrix, because matrices are rectangular by definition. Using a cell vector as in Thorsten's example is sufficient.

1 Kommentar

Anwar
Anwar am 6 Nov. 2022
hello Jan can you help me in a variable indexing task

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 9 Jan. 2013

Kommentiert:

am 6 Nov. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by