In the following script (that performs "bubble sort" on an row vector) it seems that the time elapsed when matlab executes the sorting depends exponentially on the number of elements in the vector. Why?
tic;
t=zeros(1,50);
for n=1:50
X=randi(10000,[1 n*200]);
a=length(X);
for j=1:1:a-1
for i=1:1:a-1
if X(i)>X(i+1)
temp=X(i);
X(i)=X(i+1);
X(i+1)=temp;
end
end
end
t(n)=toc;
end
plot(t)

Bubble sort requires $a^2$ comparisons (using your nomenclature). You're also including the random number creation in your time computations, so you're also counting the time it takes to generate a random vector, which you should not be including.
Here's some MATLAB code that uses
sortand pre-generates the random numbers. You can replacesortwith your own sorting algorithm to evaluate performance.Edit: Here's code using your bubble sort, and fitting a quadratic polynomial to the time-elapsed data:
And here's a plot. $At^2$ is shown in red. See how well it matches up? This coincides with the $N^2$ number of runs through the list.