<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264433</link>
    <title>MATLAB Central Newsreader - Faster and vectorized</title>
    <description>Feed for thread: Faster and vectorized</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 29 Oct 2009 10:33:21 -0400</pubDate>
      <title>Faster and vectorized</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264433#690585</link>
      <author>Oleg Komarov</author>
      <description>Dear all, &lt;br&gt;
i've been using a user defined function, written more than  one year ago, without any problem on small datasets. Since I started to work on a bigger dataset the computational time raised significanlty, i ask you therefore to help me to optimize this function.&lt;br&gt;
&lt;br&gt;
I need to compute weighted means (by row) grouped into classes&lt;br&gt;
&lt;br&gt;
Ssize = 100;&lt;br&gt;
% Example Inputs:&lt;br&gt;
% Generate Values &lt;br&gt;
Values = 10.*rand(Ssize); Values(ceil(100.*rand(Ssize/2))) = NaN; &lt;br&gt;
% Generate Weights&lt;br&gt;
Weights = 50000.*rand(Ssize); Weights(ceil(100.*rand(Ssize/2))) = NaN; &lt;br&gt;
% Generate  Classes to which values belong&lt;br&gt;
Class = floor(Ssize/10.*rand(Ssize));&lt;br&gt;
&lt;br&gt;
tic;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Out = WeMean(Values, Weights, Class); &lt;br&gt;
toc;&lt;br&gt;
&lt;br&gt;
% Elapsed time is 0.011368 seconds for Ssize = 100;&lt;br&gt;
% Elapsed time is 7.054131 seconds for Ssize = 1000;&lt;br&gt;
&lt;br&gt;
The number of elements raised by a factor of 100, the time  7.054131/0.011368 &amp;gt; 600.&lt;br&gt;
I let you imagine what happens if Ssize = 10000.&lt;br&gt;
&lt;br&gt;
% FUNCTION HERE&lt;br&gt;
function Out =  WeMean(Values, Weights, Class) &lt;br&gt;
&lt;br&gt;
% All three inputs might come from different datasets/computations so i need to &quot;align&quot; Class&lt;br&gt;
Class(isnan(Values) | isnan(Weights)) = 0; % Note that class doesn't have NaN by construction&lt;br&gt;
&lt;br&gt;
% Unique classes (0 is not a class)&lt;br&gt;
unC = setdiff(unique(Class), 0)';&lt;br&gt;
&lt;br&gt;
% Preallocate OUT&lt;br&gt;
Out = NaN(size(Values,1)+1, length(unC));&lt;br&gt;
% header row&lt;br&gt;
Out(1,:) = unC;&lt;br&gt;
&lt;br&gt;
% LOOP by class&lt;br&gt;
for i = 1 : length(unC)    &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;% Index the specific class&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IDX = Class == unC(1,i);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;% Filter the values and the weights which belong to the class&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TempV = zeros(size(Values));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TempV(IDX) = Values(IDX);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TempW = zeros(size(Weights));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TempW(IDX) = Weights(IDX);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% Denominator by row&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Den = sum(TempW, 2);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% Numerator by row&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Num = sum(TempV.*TempW,2);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% weighted mean by row&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Out(2:end,i) = Num./Den;&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
i tried to vectorize the summations (for the den and num computation) using accumarray. I avoided the loop with a subfunction which computed vectorized grouped sums. I reduced the computation time by half but accumulated eps (the approzimation is still far over e-15).&lt;br&gt;
&lt;br&gt;
Thanks in advance!&lt;br&gt;
&lt;br&gt;
Oleg</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 12:36:46 -0400</pubDate>
      <title>Re: Faster and vectorized</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264433#690623</link>
      <author>roger</author>
      <description>On Oct 29, 11:33&#160;am, &quot;Oleg Komarov&quot; &amp;lt;oleg.koma...@hotmail.it&amp;gt; wrote:&lt;br&gt;
&amp;gt; Dear all,&lt;br&gt;
&amp;gt; i've been using a user defined function, written more than &#160;one year ago, without any problem on small datasets. Since I started to work on a bigger dataset the computational time raised significanlty, i ask you therefore to help me to optimize this function.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I need to compute weighted means (by row) grouped into classes&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Ssize = 100;&lt;br&gt;
&amp;gt; % Example Inputs:&lt;br&gt;
&amp;gt; % Generate Values&lt;br&gt;
&amp;gt; Values = 10.*rand(Ssize); Values(ceil(100.*rand(Ssize/2))) = NaN;&lt;br&gt;
&amp;gt; % Generate Weights&lt;br&gt;
&amp;gt; Weights = 50000.*rand(Ssize); Weights(ceil(100.*rand(Ssize/2))) = NaN;&lt;br&gt;
&amp;gt; % Generate &#160;Classes to which values belong&lt;br&gt;
&amp;gt; Class = floor(Ssize/10.*rand(Ssize));&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; tic;&lt;br&gt;
&amp;gt; &#160; &#160; Out = WeMean(Values, Weights, Class);&lt;br&gt;
&amp;gt; toc;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Elapsed time is 0.011368 seconds for Ssize = 100;&lt;br&gt;
&amp;gt; % Elapsed time is 7.054131 seconds for Ssize = 1000;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The number of elements raised by a factor of 100, the time &#160;7.054131/0.011368 &amp;gt; 600.&lt;br&gt;
&amp;gt; I let you imagine what happens if Ssize = 10000.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % FUNCTION HERE&lt;br&gt;
&amp;gt; function Out = &#160;WeMean(Values, Weights, Class)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % All three inputs might come from different datasets/computations so i need to &quot;align&quot; Class&lt;br&gt;
&amp;gt; Class(isnan(Values) | isnan(Weights)) = 0; % Note that class doesn't have NaN by construction&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Unique classes (0 is not a class)&lt;br&gt;
&amp;gt; unC = setdiff(unique(Class), 0)';&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Preallocate OUT&lt;br&gt;
&amp;gt; Out = NaN(size(Values,1)+1, length(unC));&lt;br&gt;
&amp;gt; % header row&lt;br&gt;
&amp;gt; Out(1,:) = unC;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % LOOP by class&lt;br&gt;
&amp;gt; for i = 1 : length(unC) &#160; &#160;&lt;br&gt;
&amp;gt; &#160; &#160;% Index the specific class&lt;br&gt;
&amp;gt; &#160; &#160; IDX = Class == unC(1,i);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &#160; &#160;% Filter the values and the weights which belong to the class&lt;br&gt;
&amp;gt; &#160; &#160; TempV = zeros(size(Values));&lt;br&gt;
&amp;gt; &#160; &#160; TempV(IDX) = Values(IDX);&lt;br&gt;
&amp;gt; &#160; &#160; TempW = zeros(size(Weights));&lt;br&gt;
&amp;gt; &#160; &#160; TempW(IDX) = Weights(IDX);&lt;br&gt;
&amp;gt; &#160; &#160; % Denominator by row&lt;br&gt;
&amp;gt; &#160; &#160; Den = sum(TempW, 2);&lt;br&gt;
&amp;gt; &#160; &#160; % Numerator by row&lt;br&gt;
&amp;gt; &#160; &#160; Num = sum(TempV.*TempW,2);&lt;br&gt;
&amp;gt; &#160; &#160; % weighted mean by row&lt;br&gt;
&amp;gt; &#160; &#160; Out(2:end,i) = Num./Den;&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; i tried to vectorize the summations (for the den and num computation) using accumarray. I avoided the loop with a subfunction which computed vectorized grouped sums. I reduced the computation time by half but accumulated eps (the approzimation is still far over e-15).&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks in advance!&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Oleg&lt;br&gt;
&lt;br&gt;
losing the temp arrays may make it a bit faster. other than that&lt;br&gt;
you'll just have to live with the fact that matlab is slow with loops.&lt;br&gt;
&lt;br&gt;
for i = 1 : length(unC)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;% Index the specific class&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IDX = Class == unC(1,i);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;% weighted mean by row&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Out(2:end,i) = sum(Values(IDX).*Weights(IDX),2)./sum(Weights(IDX),&lt;br&gt;
2);&lt;br&gt;
end</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 16:11:03 -0400</pubDate>
      <title>Re: Faster and vectorized</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264433#690709</link>
      <author>Oleg Komarov</author>
      <description>&amp;gt; losing the temp arrays may make it a bit faster. other than that&lt;br&gt;
&amp;gt; you'll just have to live with the fact that matlab is slow with loops.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; for i = 1 : length(unC)&lt;br&gt;
&amp;gt;    % Index the specific class&lt;br&gt;
&amp;gt;     IDX = Class == unC(1,i);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;     % weighted mean by row&lt;br&gt;
&amp;gt;     Out(2:end,i) = sum(Values(IDX).*Weights(IDX),2)./sum(Weights(IDX),&lt;br&gt;
&amp;gt; 2);&lt;br&gt;
&amp;gt; end&lt;br&gt;
Well i loose the matrix form of the inputs if i dont make use of the temp matrices...&lt;br&gt;
unfortunately i can't suppress them in that way.</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 16:22:27 -0400</pubDate>
      <title>Re: Faster and vectorized</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264433#690715</link>
      <author>roger</author>
      <description>On Oct 29, 5:11&#160;pm, &quot;Oleg Komarov&quot; &amp;lt;oleg.koma...@hotmail.it&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; losing the temp arrays may make it a bit faster. other than that&lt;br&gt;
&amp;gt; &amp;gt; you'll just have to live with the fact that matlab is slow with loops.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; for i = 1 : length(unC)&lt;br&gt;
&amp;gt; &amp;gt; &#160; &#160;% Index the specific class&lt;br&gt;
&amp;gt; &amp;gt; &#160; &#160; IDX = Class == unC(1,i);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &#160; &#160; % weighted mean by row&lt;br&gt;
&amp;gt; &amp;gt; &#160; &#160; Out(2:end,i) = sum(Values(IDX).*Weights(IDX),2)./sum(Weights(IDX),&lt;br&gt;
&amp;gt; &amp;gt; 2);&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Well i loose the matrix form of the inputs if i dont make use of the temp matrices...&lt;br&gt;
&amp;gt; unfortunately i can't suppress them in that way.&lt;br&gt;
&lt;br&gt;
not really sure what you mean by that, if you intialize them the right&lt;br&gt;
way it shouldn't make a difference.&lt;br&gt;
Out(IDX,i) = ... may work in that sense. In fact if you make sure the&lt;br&gt;
matrices are intialized the right way you may be able to make IDX a&lt;br&gt;
matrix and use a matrix index into matrices.</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 17:03:19 -0400</pubDate>
      <title>Re: Faster and vectorized</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264433#690740</link>
      <author>Bruno Luong</author>
      <description>Try this:&lt;br&gt;
&lt;br&gt;
function Out = WeMean(Values, Weights, Class)&lt;br&gt;
&lt;br&gt;
Class(isnan(Values) | isnan(Weights)) = 0;&lt;br&gt;
[unC trash C] = unique(Class);&lt;br&gt;
[m n] = size(Class);&lt;br&gt;
I = repmat((1:m).',1,n);&lt;br&gt;
K = [I(:) C(:)];&lt;br&gt;
sz = [m length(unC)];&lt;br&gt;
Den = accumarray(K, Weights(:), sz);&lt;br&gt;
Num = accumarray(K, Values(:).*Weights(:), sz);&lt;br&gt;
filled =  accumarray(K, 1, sz);&lt;br&gt;
Out = Num./Den;&lt;br&gt;
header = unC(2:end).';&lt;br&gt;
Out= [header; Out(:,2:end)];&lt;br&gt;
Out(~filled)=NaN; % faster than fill with accumarray&lt;br&gt;
&lt;br&gt;
% Bruno</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 17:19:18 -0400</pubDate>
      <title>Re: Faster and vectorized</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264433#690752</link>
      <author>Bruno Luong</author>
      <description>The below way of indexing is more correct:&lt;br&gt;
&lt;br&gt;
...&lt;br&gt;
idx = unC ~= 0;&lt;br&gt;
header = unC(idx).';&lt;br&gt;
Out= [header; Out(:,idx)];&lt;br&gt;
...&lt;br&gt;
&lt;br&gt;
% Bruno</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 17:44:02 -0400</pubDate>
      <title>Re: Faster and vectorized</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264433#690764</link>
      <author>Bruno Luong</author>
      <description>Oops, one more bug corrected&lt;br&gt;
&lt;br&gt;
function Out = WeMean(Values, Weights, Class)&lt;br&gt;
&lt;br&gt;
Class(isnan(Values) | isnan(Weights)) = 0;&lt;br&gt;
[unC trash C] = unique(Class);&lt;br&gt;
[m n] = size(Class);&lt;br&gt;
I = repmat((1:m).',1,n);&lt;br&gt;
K = [I(:) C(:)];&lt;br&gt;
sz = [m length(unC)];&lt;br&gt;
Den = accumarray(K, Weights(:), sz);&lt;br&gt;
Num = accumarray(K, Values(:).*Weights(:), sz);&lt;br&gt;
filled = accumarray(K, 1, sz);&lt;br&gt;
Out = Num./Den;&lt;br&gt;
idx = unC ~= 0;&lt;br&gt;
Out(filled&amp;gt;0)=NaN; % faster than fill with accumarray&lt;br&gt;
header = unC(idx).';&lt;br&gt;
Out= [header; Out(:,idx)];&lt;br&gt;
&lt;br&gt;
% Bruno</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 18:13:05 -0400</pubDate>
      <title>Re: Faster and vectorized</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264433#690783</link>
      <author>Oleg Komarov</author>
      <description>&quot;Bruno Luong&quot; &amp;lt;b.luong@fogale.findmycountry&amp;gt; wrote in message &amp;lt;hcck92$28n$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Oops, one more bug corrected&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; function Out = WeMean(Values, Weights, Class)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Class(isnan(Values) | isnan(Weights)) = 0;&lt;br&gt;
&amp;gt; [unC trash C] = unique(Class);&lt;br&gt;
&amp;gt; [m n] = size(Class);&lt;br&gt;
&amp;gt; I = repmat((1:m).',1,n);&lt;br&gt;
&amp;gt; K = [I(:) C(:)];&lt;br&gt;
&amp;gt; sz = [m length(unC)];&lt;br&gt;
&amp;gt; Den = accumarray(K, Weights(:), sz);&lt;br&gt;
&amp;gt; Num = accumarray(K, Values(:).*Weights(:), sz);&lt;br&gt;
&amp;gt; filled = accumarray(K, 1, sz);&lt;br&gt;
&amp;gt; Out = Num./Den;&lt;br&gt;
&amp;gt; idx = unC ~= 0;&lt;br&gt;
&amp;gt; Out(filled&amp;gt;0)=NaN; % faster than fill with accumarray&lt;br&gt;
&amp;gt; header = unC(idx).';&lt;br&gt;
&amp;gt; Out= [header; Out(:,idx)];&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % Bruno&lt;br&gt;
&lt;br&gt;
There's something in the:&lt;br&gt;
&amp;gt; Out(filled&amp;gt;0)=NaN; % faster than fill with accumarray&lt;br&gt;
row that doesn't work the right way. The output is all NaNs...</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 18:39:06 -0400</pubDate>
      <title>Re: Faster and vectorized</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264433#690787</link>
      <author>Oleg Komarov</author>
      <description>&amp;gt; There's something in the:&lt;br&gt;
&amp;gt; Out(filled&amp;gt;0)=NaN; % faster than fill with accumarray&lt;br&gt;
&amp;gt; row that doesn't work the right way. The output is all NaNs...&lt;br&gt;
replaced &quot;&amp;gt;&quot; with &quot;==&quot;;&lt;br&gt;
&lt;br&gt;
BRUNO'S &lt;br&gt;
&lt;br&gt;
function Out = WeMean2(Values, Weights, Class)&lt;br&gt;
Class(isnan(Values) | isnan(Weights)) = 0; % Align Class to Values and Weights&lt;br&gt;
[unC, ~, C] = unique(Class); % Unique di Class and col sub&lt;br&gt;
[m n] = size(Class); % Class dimensions&lt;br&gt;
I = repmat((1:m).',1,n); % row sub&lt;br&gt;
K = [I(:) C(:)]; % subs&lt;br&gt;
sz = [m length(unC)]; % Out dimensions&lt;br&gt;
Den = accumarray(K, Weights(:), sz); % Denominator&lt;br&gt;
Num = accumarray(K, Values(:).*Weights(:), sz); % Numerator&lt;br&gt;
Out = Num./Den; % Output&lt;br&gt;
filled = accumarray(K, 1, sz); % Clear not filled with NaN&lt;br&gt;
Out(filled == 0) = NaN; % major sign replaced with ==&lt;br&gt;
% Place header&lt;br&gt;
idx = unC ~= 0;&lt;br&gt;
header = unC(idx).';&lt;br&gt;
Out= [header; Out(:,idx)];&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
MINE&lt;br&gt;
(look at the first post)&lt;br&gt;
&lt;br&gt;
Perfomance check and same result..&lt;br&gt;
&lt;br&gt;
for Ssize = 10:100:900;&lt;br&gt;
Values = 10.*rand(Ssize); Values(ceil(100.*rand(Ssize/2))) = NaN; % Generate Values&lt;br&gt;
Weights = 50000.*rand(Ssize); Weights(ceil(100.*rand(Ssize/2))) = NaN; % Generate Weights&lt;br&gt;
Class = floor(Ssize*2/5.*rand(Ssize)); % Generate Classes to which values belong&lt;br&gt;
&lt;br&gt;
tic; A = WeMean(Values, Weights, Class); toc; % Mine&lt;br&gt;
tic; B = WeMean2(Values, Weights, Class); toc; % Bruno's&lt;br&gt;
&lt;br&gt;
isequalwithequalnans(A,B); % always verified&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
Elapsed time is 0.001306 seconds.&lt;br&gt;
Elapsed time is 0.001084 seconds.&lt;br&gt;
&lt;br&gt;
Elapsed time is 0.033996 seconds.&lt;br&gt;
Elapsed time is 0.008017 seconds.&lt;br&gt;
&lt;br&gt;
Elapsed time is 0.232533 seconds.&lt;br&gt;
Elapsed time is 0.028339 seconds.&lt;br&gt;
&lt;br&gt;
Elapsed time is 0.714834 seconds.&lt;br&gt;
Elapsed time is 0.063467 seconds.&lt;br&gt;
&lt;br&gt;
Elapsed time is 1.705921 seconds.&lt;br&gt;
Elapsed time is 0.077690 seconds.&lt;br&gt;
&lt;br&gt;
Elapsed time is 2.787658 seconds.&lt;br&gt;
Elapsed time is 0.166200 seconds.&lt;br&gt;
&lt;br&gt;
Elapsed time is 4.025173 seconds.&lt;br&gt;
Elapsed time is 0.222698 seconds.&lt;br&gt;
&lt;br&gt;
Elapsed time is 6.259864 seconds.&lt;br&gt;
Elapsed time is 0.259810 seconds.&lt;br&gt;
&lt;br&gt;
Elapsed time is 9.305980 seconds.&lt;br&gt;
Elapsed time is 0.376411 seconds.&lt;br&gt;
&lt;br&gt;
And the winneeeeeerrr is BRUNO!&lt;br&gt;
&lt;br&gt;
I tried to implement a solution with accumarray but as i wrote in the firt post but could't accomplish what u did.</description>
    </item>
    <item>
      <pubDate>Wed, 04 Nov 2009 18:49:04 -0500</pubDate>
      <title>Re: Faster and vectorized</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264433#692149</link>
      <author>Oleg Komarov</author>
      <description>&amp;gt; &quot;Bruno Luong&quot; &amp;lt;b.luong@fogale.findmycountry&amp;gt; wrote in message &amp;lt;hcck92$28n$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; &amp;gt; Out(filled==0)=NaN; % faster than fill with accumarray&lt;br&gt;
&amp;gt; &amp;gt; % Bruno&lt;br&gt;
&amp;gt; &lt;br&gt;
I would also add that results differ slightly if using inbuilt fill option. </description>
    </item>
  </channel>
</rss>

