フィルターのクリア

concatenation in a loop

44 ビュー (過去 30 日間)
Aniket Kumar
Aniket Kumar 2019 年 6 月 8 日
回答済み: Prasanth Sikakollu 2019 年 6 月 8 日
Can we concatenate two matrices in a loop? (size of one matrix will increase after every iteration)
for me its showing this error
"Error using cat
Dimensions of matrices being concatenated are not consistent."
  1 件のコメント
madhan ravi
madhan ravi 2019 年 6 月 8 日
Show the code.

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

採用された回答

Prasanth Sikakollu
Prasanth Sikakollu 2019 年 6 月 8 日
For row wise concatenation:
Here, matrix 'c' is being concatenated to matrix 'a' row wise, number of columns being constant in this case.
a = [];
c = [1 2;3 4];
for i = 1:5
c = [1*i 2*i;3*i 4*i];
a = [a;c]; % For row wise concatenation
end
For column wise concatenation:
Here matrix 'c' is being concatenated to matrix 'a' column wise, number of rows being constant in this case.
a = [];
c = [1 2;3 4];
for i = 1:5
c = [1*i 2*i;3*i 4*i];
a = [a c]; % For column wise concatenation
end
Hope this helps

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by