From: Matt Fig on 6 Apr 2010 12:10 "mikin Nede" <mnedelj(a)gmail.com> wrote in message <hpfld0$q9h$1(a)fred.mathworks.com>... > "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hpf71k$5i3$1(a)fred.mathworks.com>... > > Dear Mik! > > Hello Jan! > > Thanks a lot for the tip, it does speed it up for ~ 1.5s, but as you also said, it is > LW_temp = (LW*beta(:,jj)); > L = f(LW_temp); > > that takes most of the time. Function f() is simple: > > f=@(u)(1-(0.2*(u.^2))).*(u.^2<5); > > and it takes time if I evaluate it within the loop or if I vectorize and do it pointwise on say 2000X5000 matrix (because otherwise I run out of memory). Needless to say, am grateful for any suggestions that you might have. > > Cheers, > Mik I would get rid of the function evaluation and just use: L = max(1-(0.2*(u.^2)),0); That should be faster.
From: Jan Simon on 6 Apr 2010 16:16 Hi! > L = max(1-(0.2*(u.^2)),0); I've seen some Matlab issues before, that this is faster: L = 1 - (0.2 * (u .^ 2)); L(L > 0) = 0; But this may be outdated. Jan
From: mikin Nede on 7 Apr 2010 06:34 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hpg4qj$874$1(a)fred.mathworks.com>... > Hi! > > Hello Matt and Jan, Thanks a lot guys, replacing the function evaluation cuts the time by 2, so guess I won't need to rely on mex for now. Using max(u,0) is a bit faster. Cheers Mik
First
|
Prev
|
Pages: 1 2 Prev: video compression using matlab code Next: PITCH ESTIMATION matlab code |