How to improve my code speed (for loop)
Ältere Kommentare anzeigen
T = clasval.T;
Gamma_x = clasval.Gamma_x;
Gamma_xy = clasval.Gamma_xy;
Gamma_y = clasval.Gamma_y;
ut = clasval.ut;
[nsamples,dim]=size(trainingsset);
scorematrix=zeros(nsamples,nsamples);
for i=1:nsamples
for j=1:nsamples
probe=trainingsset(i,:);
gallery=trainingsset(j,:);
llr_score;
scorematrix(j,i)=score;
if i == j
break;
end
end
end
I would like to improve the speed f the following code. I already tried preallocating scoreamatrix, but it is still very slow. The code llr_score.m contains the following:
x=T*(probe-ut)';
y=T*(gallery-ut)';
score=x'*Gamma_x*x + x'*Gamma_xy*y+y'*Gamma_y*y;
4 Kommentare
Fabio Freschi
am 9 Jun. 2020
what are the dimensions of T and ut? Can you provide a MWE?
Marleen van Dijk
am 9 Jun. 2020
Fabio Freschi
am 9 Jun. 2020
is dim always 1?
Marleen van Dijk
am 9 Jun. 2020
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Special Functions finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
