# I want to ask if it is possible to add these two horizontal matrices and if so, how?

조회 수: 1(최근 30일)
Man-Ishar 2022년 11월 25일
답변: Walter Roberson 2022년 11월 25일
T = [1 3 6; 6 5 8; 7 8 -2; 8 -9 8; 3 -1 -7]
S = [6;8;-2;8;-7;4;9;-8;3;-2]

댓글을 달려면 로그인하십시오.

### 답변(2개)

the cyclist 2022년 11월 25일
As shown below, these two arrays have different sizes, and not even the same number of elements. Tt is very unclear, mathematically, what it means to "add" them.
Can you tell us what you mean? What do you expect the result to be?
T = [1 3 6; 6 5 8; 7 8 -2; 8 -9 8; 3 -1 -7];
S = [6;8;-2;8;-7;4;9;-8;3;-2];
size(T)
ans = 1×2
5 3
size(S)
ans = 1×2
10 1
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

댓글을 달려면 로그인하십시오.

Walter Roberson 2022년 11월 25일
No, it is not possible. The first one is 5 x 3 and the second is 10 x 1.
You can extract the first 5 rows of S and add that to T, giving a 5 x 3 result.
You can imresize(T) to have 10 rows, same as S
You can repmat(T,2,1) or repelem(T,2,1) to have 10 rows, same as S
You can
ifft(fft(T), size(S,1)) + S

댓글을 달려면 로그인하십시오.

### 범주

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

R2022b

### Community Treasure Hunt

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

Start Hunting!

Translated by