How to speed up this function?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jonathan Mayers
el 26 de Mayo de 2016
Respondida: Jonathan Mayers
el 26 de Mayo de 2016
Hi all,
I am calculating a value Gamma as shown in the image below.
I have implemented this calculation as a for-loop and I suspect it could be done without using a for-loop and be faster. Every h term is the jth column of an NxK matrix and Pj is the jth column of KxK diagonal matrix P. What is the fastest way to calculate this value?
function [ GAMMA ] = gamma_dnc( P,Hh,Ht,K )
%GAMMA_DNC Calculates the component GAMMA in the DNC
% beamforming matrix V.
% Running total
total = 0;
for j = 1:K
p = P(j,j); % Select jth column of P
ht = Ht(:,j); % Select jth column of Ht
hh = Hh(:,j); % Select jth column of Hh
% Perform summation
h1 = ht*(hh');
h2 = hh*(ht');
h3 = ht*(ht');
h4 = h1 + h2 + h3;
total = total + p*h4;
end
GAMMA = mean2(total);
end
1 comentario
James Tursa
el 26 de Mayo de 2016
What are the dimensions of the variables? And which variables are complex?
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!