Hi, I would like to save a vector (size change at every loop) in a matrix

1 回表示 (過去 30 日間)
RogerLM
RogerLM 2016 年 6 月 23 日
コメント済み: RogerLM 2016 年 6 月 23 日
I would like to divide a vector in many vectors and put all of them in a matrix. I got this error "Subscripted assignment dimension mismatch."
STEP = zeros(50,1);
STEPS = zeros(50,length(locate));
for i = 1:(length(locate)-1)
STEP = filtered(locate(i):locate(i+1));
STEPS(:,i) = STEP;
end
I take the value of "filtered" from (1:50) at the first time for example and I would like to stock it in the first row of a matrix, then for iterations 2, I take value of "filtered from(50:70) for example and I stock it in row 2 in the matrix, and this until the end of the loop..
If someone has an idea, I don't get it! Thank you!

回答 (1 件)

Jos (10584)
Jos (10584) 2016 年 6 月 23 日
Vectors with different sizes cannot be stacked into a single array. You can, for instance, use cell arrays as an alternative.
C = cell(5,1) ;
for k=1:5,
C{k} = 1:k ; % vectors with different sizes on each iteration
end

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by