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

조회 수: 2 (최근 30일)
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
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

Walter Roberson
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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by