MATLAB: Problem using quadv

dependent vairablesintegrationMATLABquadquadvvectorization

I am having problems trying to compute the values for the two vector variables.
Each vector has 31 elements but my computations should be 31 *31 in dimensions.
If anyone could advise me on possible corrections that would be great.
Thanks in advance,
Courtney
I have included my program below:
function [Teval] = TInt2(x,t)
% [Teval] = function to evaluate the integral: exp(-u^2)
% f(x,t)= 2/sqrt(pi)* intergral
% Integration limits: lower = 0, upper = x/2*sqrt(alpha*time(sec))
% Function Call: TInt2((0:.1:3),(0:1:30))
%inputs:
% x=depth in meters
% t=time in days
% Sub function:
%function [Tu] = Tfield(u)
%Tu = exp((-u).^2);
%end
a=0.138e-6;%alpha constant
step=8.64e4;%conversion of days into seconds
n = length(t); %find the number of elements in time
m = length(x);
i = 1; %loop variable
j = 1;
global d; %make time element global for field function
global f;
while(i <= n)
d = t(1,i)*step
i = i+1;
end
while(j <= m)
f = x(1,j)
j = j+1;
end
limit = (f(1,:)./(2*sqrt(d(1,:).*a)))
eval(1,[]) = quadv(@Tfield,0,limit);
Teval = (2/sqrt(pi))*eval;
ploy3(Teval(:,1),f(:,1),d(:,1))
end

Best Answer

You have
while(i <= n)
d = t(1,i)*step
i = i+1;
end
But you probably want
for i = 1 : n
d(1,i) = t(1,i)*step
end
which in turn could be optimized to
d = t .* step;
with no loop at all.