MATLAB: Faster than for loop

for loop; vectorization; optimize; fast

I presently have this code which tests a paricular function which I created _ _ [y n] function_gen1pdf1(a,b,c) _ _ for N times. Now this works fine up to N=100. However, I want it to work for N=100,000 but it's taking much too long to compute. Is it possible to vectorize it or make it work faster? Any suggestions are much appreciated!
N=100000;
y=zeros(N,1);
n=zeros(N,1);
for i=1:N; %testing the function for 100000 times
[y(i) n(i)]= function_gen1pdf1(2,3,0.5); %The function being tested
end

Best Answer

It's your function, it's not the for loop. If you just run a for loop 100,000 times it takes 0.2 milliseconds.
I tried it:
tic
for k = 1 : 100000
;
end
toc
Elapsed time is 0.000219 seconds.
So it if takes a long time, it's due to your function_gen1pdf1() function.