How can i save a vector with a variable length ?

7 ビュー (過去 30 日間)
Adrin
Adrin 2013 年 1 月 9 日
コメント済み: Anwar 2022 年 11 月 6 日
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,

採用された回答

Thorsten
Thorsten 2013 年 1 月 9 日
Use a cell V to store the vectors
for i = 1:N
vec_of_variable_length = ...
V{i} = vec_of_variable_length;
end
  1 件のコメント
Adrin
Adrin 2013 年 1 月 9 日
Thank you...

サインインしてコメントする。

その他の回答 (1 件)

Jan
Jan 2013 年 1 月 9 日
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 件のコメント
Anwar
Anwar 2022 年 11 月 6 日
hello Jan can you help me in a variable indexing task

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by