function W= Nconvolve(t_end, beamdistance, i1,i2,j)
k=(0:.001:t_end);
for h=(1:length(k))
g= (TwoDG(k(h), beamdistance, i1, i2,j));
D(:,:,h)=g;
end
x1= (-.004:.001:.004);
x2= (-.004:.001:.004);
for f= (1:length(x1))
for e= (1:length(x2))
for h=(1:length(k))
sigma_x= 1;
sigma_z= 1;
F(f,e) = exp((-((x1(f))^2)/(2*((sigma_x)^2)))-(((x2(e))^2)/(2*((sigma_z)^2))));
Q(:,:,h)=F;
end;
end;
end;
X= fft([D zeros(1,length(Q)-1)]);
Y= fft([Q zeros(1,length(New)-1)]);
W= ifft(X.*Y);
but when i run this, it tells me that
"Assignment has more non-singleton rhs dimensions than non-singleton
subscripts
Error in ==> Nconvolve at 23
Q(:,:,h)=F;"
and I cannot figure out why. Any advice? Thanks in advance.
This doesn't exactly answer your question, but do you know about convn, or fftn? Also, your triple loop doesn't really make sense. For one, you can eliminate the 'e' and 'f' loops by using meshgrid and computing F for vector arguments instead of scalar. sigma_x and sigma_z are constant so they should be defined outside the loop. Q doesn't seem to depend on h, so why are you looping over h? You might use repmat instead.
I see error; but I think it's better you see by yourself. Use DBSTOP IF ERROR, run your code and check the dimensions for Q and F.
Bruno
As an example, suppose size(F) = [m,n,p,q,r] and you have an assignment like
Q(1:m,1:n)=F;
This is only a valid assignment if p=q=r=1. Otherwise, you get the error message indicated.