Im trying to make my function run faster and I was wondering if anyone can help me. I'm trying to calculate the following equation :
ImageShack - Image Hosting :: 29384513.jpg
where N and M are inputs. Basically i need to caluclate that sum for all values of m.
This is my current code:
function [e] = new5(M,N)
%plot histogram of data
Something like (this is untested by the way, so no guarantees):
CBCode:N=3;M=4; tic; k=3; BlockLen=1000; e=zeros(1,M-1); m=1:M-1; for idx=1:1000:N n=(idx:min(N,idx+BlockLen-1)); d=m/M; theta=n'.^k*d; b=cos(theta); e=e+sum(b)/sqrt(N); end hold on plot histogram of data hist(e,100);figure(gcf); hold off toc