offset matrix multiplication with loop
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Emilio Alverio
il 6 Feb 2018
Commentato: Emilio Alverio
il 8 Feb 2018
Hello,
I have two matrices A(i,j) and B(i,j) where 'i' is row and 'j' is column both of size 1486X41. I am trying to use a loop to multiply the two together such that the first term in each column of A is skipped, I.E. multiply A(2,1) with B(1,1) to give C(1,1) and then A(3,1) with B(2,1) for C(2,1) and so on. The final matrix size will be now 1485X41. I've attempted using a for loop but I struggle with thinking through the code. So far my efforts have led me to:
for i = 1:(length(A)-1)
at = A(i+1)-A(1)
C = B*at
end
I hope my question is clear, and I apologize in advanced for any confusion with the wording. Thank you.
0 Commenti
Risposta accettata
Jos (10584)
il 6 Feb 2018
% test data
A = randi(10,3,4)
B = cumsum(ones(size(A)))
% engine
C = A(2:end,:) .* B(1:end-1,:) % C(i,j) = A(i+1,j) * B(i,j)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!