MATLAB: Efficiently repeating nullspace operation

MATLABnull spacespeed

I need to repeat alot of null-space operations (of 3 x 4 matrices) , and is looking for a way to improve speed. I am trying to work with matrices, and essentially what I want to do, if possible, is to increase speed between "tic" and "toc" in the following:
n=1e6;
Trow1=rand(n,4);
Trow2=rand(n,4);
Trow3=rand(n,4);
tic
Vh=zeros(n,4);
for i=1:n
Vh(i,:)=null([ Trow1(i,:); Trow2(i,:); Trow3(i,:)] );
end
toc
I am not looking for methods involving parallelization, but was hoping that I somehow could avoid the for-loop, or similar.

Best Answer

Here is one more method, so far fastest and derived from a much more direct calculation.
The idea is like this : For a fix matrix A (4x3), Vh is null(A') is a vector of norm_l2=1 that maximizes det([A, Vh]), I assume A is fullrank though.
Cauchy–Schwarz's inequality proof tells us that it maximizes when Vh is correlated to 3x3 sub-determinants of A. So I use to compute directly Vh.
The idea can be extended for any dimension array p x (p-1). For example for p==3, we gets the formula of the cross-product.
n=1e5;
Trow1=rand(n,4);
Trow2=rand(n,4);
Trow3=rand(n,4);
tic
T1 = reshape(Trow1.',[4 1 n]);
T2 = reshape(Trow2.',[4 1 n]);
T3 = reshape(Trow3.',[4 1 n]);
T = cat(2,T1,T2,T3);
[p,q,n] = size(T);
rdet(q);
c = 1:q;
Vh = zeros(p,n);
for i=1:p
ri = setdiff(1:p,i);
Vh(i,:) = (-1)^(i-1)*rdet(T,ri,c);
end
Vh = (Vh ./ sqrt(sum(Vh.^2,1))).';
toc % Elapsed time is 0.099139 seconds. (PS: run on different computer than before)
% Compute determinant recursively with bookeeping
function d = rdet(A,r,c)
persistent RC D
if nargin == 1
% Reset data-base
q = A;
RC = cell(1,q);
for k=1:q
RC{k} = zeros(0,2*k);
end
D = cell(1,q);
return
end
q = length(r);
if q == 1
d = A(r,c,:);
return
end
[tf,loc] = ismember([r,c],RC{q},'rows');
if tf
d = D{q}(loc,1,:);
return
end
% Update the row-column database
RC{q}(end+1,:) = [r,c];
% Recursive call of determinant
A1 = A(r,c(1),:);
c(1) = [];
di = zeros(size(A1));
for i=1:q
ri = r;
ri(i) = [];
di(i,1,:) = rdet(A,ri,c);
end
A1(2:2:end,1,:) = -A1(2:2:end,1,:);
d = sum(A1.*di,1);
% Store the result
D{q}(end+1,1,:) = d;
end