How it is possible to sum these two matrix as a vector?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148052/image.jpeg)
2 Kommentare
Lukas Bystricky
am 14 Aug. 2015
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?
Akzeptierte Antwort
Lessmann
am 14 Aug. 2015
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
Weitere Antworten (1)
Bjorn Gustavsson
am 14 Aug. 2015
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
0 Kommentare
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!