You can use 'prctile' on the flattened array to calculate the 25th percentile which in turn will give you the first quartile.
a = rand(1024,1024);
a_flattened = a(:);
out = prctile(a_flattened,25)
You can refer to the documentation page of 'prctile' for more information on the same by executing the following command from MATLAB command window.
doc prctile
Thanks!