Turning a product of two vectors into a matrix without using for loops?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
daniel adams
le 8 Oct 2021
Réponse apportée : Star Strider
le 8 Oct 2021
I have to two vectors x and y, each of length n. I want a matrix M where the elements of M are . How can I construct M on matlab without using a for loop?
0 commentaires
Réponse acceptée
Star Strider
le 8 Oct 2021
I believe something like this should do what you want —
x = 1:10
y = 11:20
M = x(:)*y
Using ‘x’ as x(:) forces it to become a column vector. The rest is straightforward vector-matrix multiplication.
.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!