<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000'><font face="times new roman, new york, times, serif"><span style="font-size: 12pt;">Hi All</span></font><br><br><font face="times new roman, new york, times, serif"><span style="font-size: 12pt;">Is the vectorization possible for the example herebellow? everything I tried failed !</span></font><br><br><font face="times new roman, new york, times, serif"><span style="font-size: 12pt;">Thanks for any help</span></font><br><br><font face="times new roman, new york, times, serif"><span style="font-size: 12pt;">Paul</span></font><br><br><font face="times new roman, new york, times, serif"><span style="font-size: 12pt;">##################################################################</span></font><br><div><div><font face="times new roman, new york, times, serif">mode(0)</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">k = 100;</font></div><div><font face="times new roman, new york, times, serif">a = rand(k,1);</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">w = 5;</font></div><div><font face="times new roman, new york, times, serif">n = (k/w);</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">i = [1 : n]';</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">tmp = zeros(n,1);</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">// using vectorization</font></div><div><font face="times new roman, new york, times, serif">tmp(i,1) = sum(a( [1 + (i-1)*n : i*n],:)</font></div><div><font face="times new roman, new york, times, serif">abort</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">// same using a loop</font></div><div><font face="times new roman, new york, times, serif">for i = 1 : n</font></div><div><font face="times new roman, new york, times, serif">    tmp(i,1) = sum(a( [1 + (i-1)*w : i*w],:));</font></div><div><font face="times new roman, new york, times, serif">end</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">tmp</font></div></div></div></body></html>