How it is possible to sum these two matrix as a vector?

조회 수: 2 (최근 30일)
Habib
Habib 2015년 8월 14일
댓글: Habib 2015년 8월 14일
Hi guys.
I'd like to write summation these two matrix as two vectors that defined as C1 And C2 .For writing a program for it in the matter, I need some help, what must I do?
  댓글 수: 2
Lukas Bystricky
Lukas Bystricky 2015년 8월 14일
What exactly are you trying to do? My guess is that given i and j, you want to calculate C1 and C2, it that right?
Habib
Habib 2015년 8월 14일
Thanks for your answer.
yes. that's right. My goal is their calculation.
but I think the approach is like below method (I am not sure):
after calculation c1 will be a matrix (but indeed, it is a vector that its components are matrix) that its elements is:
c11=[9i+9i , 9i+13j, 9i+5j, 9i+2j]
c12=[8i+9i , 8i+13j, 8i+5j, 8i+2j]
.
.
.
c44=[2i+14i , 2i-3j, 2i+7j, 2i+10j]
c11, c12 ... c44 are vector and belonging to c1 matrix.
so what is solution?

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

채택된 답변

Lessmann
Lessmann 2015년 8월 14일
If I understand you right, this should do it.
function [C1,C2] = foo(A,B)
C1 = zeros(16,4);
C2 = zeros(16,4);
itc = 1;
for itb = 1:4
for ita = 1:4
C1(itc,:) = A(itb,ita)+B(itb,:);
C2(itc,:) = B(itb,ita)-A(itb,:);
itc = itc+1;
end
end
  댓글 수: 1
Habib
Habib 2015년 8월 14일
thanks.
your answer is correct. but its result is not what I want.

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

추가 답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2015년 8월 14일
Since you have hats on i and j I assume they are column vectors, then your function might very well look something like this
function [C1,C2] = add_transformedvectors(i,j,A,B)
% Fill in help comments
% If ambitious fill in additional argument checks and such
C1 = A*i + B*j;
C2 = B*i - A*j;
HTH

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by