How to multiply two matrices with nested for loops ?
Afficher commentaires plus anciens
How can I do that with two matrices with any dimensions that can multiply ? Thank you
1 commentaire
kale jabbar
le 11 Fév 2018
Modifié(e) : kale jabbar
le 11 Fév 2018
A=input
b=input
c=[ ]
R=size(A)
G=size(b)
n=R(1)
m=G(2)
for i=1:n
for j=1:m
c(i,j)=A(i,:)*b(:,j)
end
end
c
Réponse acceptée
Plus de réponses (2)
pallab
le 9 Jan 2025
0 votes
write a user define matrix multiplication function using if and for loop
1 commentaire
Walter Roberson
le 9 Jan 2025
Well, you certainly can do that, but you have not explained how to do that, and so this answer is not at all useful in answering the question posed of how to write such code.
I admit to being rather unclear as to the benefit of using "if" statements in the matrix multiplication code? I can see using "if" in the initial tests to verify matrix size compatibility though.
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!