How to to add column 3rd+4th, 6th+7th and 9th+10th from a 8x12 matrix?

1 回表示 (過去 30 日間)
Amdad Chowdury
Amdad Chowdury 2022 年 11 月 29 日
回答済み: Jan 2022 年 11 月 29 日
I want to add column 3rd+4th, 6th+7th and 9th+10th from the matrix B. I want to apply the rule for a 2D sparse matrix.
A = [1,2,3;4,5,6]
A = 2×3
1 2 3 4 5 6
N=4;
B = kron(eye(N),A)
B = 8×12
1 2 3 0 0 0 0 0 0 0 0 0 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 0 0 0 0 0 0 0 0 0 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 0 0 0 0 0 0 0 0 0 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 0 0 0 0 0 0 0 0 0 4 5 6

回答 (1 件)

Jan
Jan 2022 年 11 月 29 日
C1 = B(:, 3) + B(:, 4);
C2 = B(:, 6) + B(:, 7);
C3 = B(:, 9) + B(:, 10);
Or maybe:
C = B(:, [3,6,9]) + B(:, [4,7,10])

カテゴリ

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