I want to change the size of T so I can Add it to P2 (the size of T should be the size of P1 or the size of P2)

조회 수: 1 (최근 30일)
P1=[3 2 4;2 1 1;5 2 3;2 3 7]
P2=[2 6 1;1 3 5;4 2 1;5 2 1];
P1_Zero=pinv(P1)
T=P1_Zero*P1
Q=P2+T
  댓글 수: 2
Image Analyst
Image Analyst 2021년 12월 15일
Original question:
I want to change the size of T so I can Add it to P2 (the size of T should be the size of P1 or the size of P2)
P1=[3 2 4;2 1 1;5 2 3;2 3 7]
P2=[2 6 1;1 3 5;4 2 1;5 2 1];
P1_Zero=pinv(P1)
T=P1_Zero*P1
Q=P2+T

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

채택된 답변

Awais Saeed
Awais Saeed 2021년 9월 16일
편집: Awais Saeed 2021년 9월 16일
P1=[3 2 4;2 1 1;5 2 3;2 3 7];
P2=[2 6 1;1 3 5;4 2 1;5 2 1];
P1_Zero=pinv(P1);
T=P1_Zero*P1;
% create a new matrix of dimension equal to max(T,P2)
C = zeros(max(size(T), size(P2)))
C = 4×3
0 0 0 0 0 0 0 0 0 0 0 0
% Make C(size(T)) = T. rest = zero
C(1:size(T, 1), 1:size(T, 2)) = T
C = 4×3
1.0000 0 0.0000 0.0000 1.0000 -0.0000 -0.0000 -0.0000 1.0000 0 0 0
% Add both EQUAL matrices now
C = C + P2
C = 4×3
3.0000 6.0000 1.0000 1.0000 4.0000 5.0000 4.0000 2.0000 2.0000 5.0000 2.0000 1.0000

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by