Effacer les filtres
Effacer les filtres

How to vectorize this ?

1 vue (au cours des 30 derniers jours)
Alex Kurek
Alex Kurek le 2 Mai 2016
Modifié(e) : Stephen23 le 2 Mai 2016
It seems I dont understand sth about vectorization.
Aj = zeros(1, jCount); % it is filled in reality, but here I just swoh the size
uj = zeros(K, jCount); % as above
for angle = 1:K
currentUj = uj(angle, :);
beta(angle) = sum(Aj.*currentUj);
end
Can somebody show me how to vectorize this, so I can learn what I do wrong?
Best regards, Alex

Réponse acceptée

Stephen23
Stephen23 le 2 Mai 2016
Modifié(e) : Stephen23 le 2 Mai 2016
This does that same as your loop:
beta = sum(bsxfun(@times,Aj,uj),2).';

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by