Multiplying two vectors to form a matrix
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I have two vectors x and y, both 601x1. I want to multiply them to form a matrix of 601x601, but the values inside the matrix have to be sqrt(x^2+y^2). How do I do this? Thanks.
0 commentaires
Réponse acceptée
Plus de réponses (2)
KSSV
le 25 Fév 2022
x = rand(601,1) ;
y = rand(601,1) ;
iwant = sqrt(x.^2+y'.^2) ;
size(iwant)
0 commentaires
Walter Roberson
le 25 Fév 2022
D = sqrt(x.'.^2 + y.^2)
4 commentaires
Jan
le 25 Fév 2022
@Nikola Segedin: Which Matlab versionare you using? Since R2016b an "implicit expanding" is applied. For former versions:
D = sqrt(bsxfun(@plus, x.'.^2, y.^2))
Voir également
Catégories
En savoir plus sur Logical 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!