For loop taking only last column

6 ビュー (過去 30 日間)
Davide Martintoni
Davide Martintoni 2021 年 1 月 31 日
コメント済み: Adam Danz 2021 年 2 月 2 日
Hi,
I am trying a code that creates two vector columns (36x1) and then store the two columns in a matrix. The problem is that the code is repeating the second column sector when storing it in a vector. I tried several option with the foor loops but the results doesn't change. Matrice is matrix in english if it can help!
for i=1:5:6
%here i start from a big matrix and I take 4 rows for each iteration, all columns
x_kalman_rolling_matrice_for = x_kalman_rolling_matrice(i+2:i+5,1:36);
for i=1:2
%here i take all rows from a matrix, but only the first 36 columns (in second iteration from the 2nd to the 37th column);
regressori_girati_for = regressori_girati(:,i:i+35);
for i=1:36
%here i compute a number given by the transpose of a columns from the x_kalman_rolling_matrice_for, so a row, and I multiply it by a column
fitted_kalman_rolling = transpose(x_kalman_rolling_matrice_for(:,i))*regressori_girati_for(:,i);
fitted_kalman_rolling_matrice(i,1)=fitted_kalman_rolling; %here I put one numnber under the other to create a vector
end
end
for i=1:2
fitted_kalman_rolling_matrice_grande(:,i) = [fitted_kalman_rolling_matrice]; %here I would like the two vector to be written one column after the other
%but printing the results shows me that the code is taking only the second vector
end
end
  10 件のコメント
Bjorn Gustavsson
Bjorn Gustavsson 2021 年 2 月 2 日
That was what I always used to (but then my memory went somewhere I didn't follow), but I too often forgot which order I had i, j and k. Now I only rely on remembering the order of the natural numbers, when that goes I figure people will tell me to stop messing up programming?
Adam Danz
Adam Danz 2021 年 2 月 2 日
😄

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by