Assignment has more non-singleton rhs dimensions than non-singleton subscripts

Show

Kevin

unread,

Jul 14, 2009, 11:16:03 PM7/14/09

to

Hello I'm trying to make two matrices and use fourier transforms to effectively take a 3D convolution of the functions that the matrices represent. My code is as follow:

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.

Alan B

unread,

Jul 14, 2009, 11:37:01 PM7/14/09

to

"Kevin " <> wrote in message <h3i3v3$rn6$>...

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.

Kevin

unread,

Jul 15, 2009, 1:57:05 AM7/15/09

to

Well I am trying to make Q a 3D matrix that has the value of F through each step of time (represented by h), so by looping through h I was attempting to fill the 3D matrix with the solution to F at each time point. I just don't understand why that causes an error.

Bruno Luong

unread,

Jul 15, 2009, 3:00:18 AM7/15/09

to

"Kevin " <> wrote in message <h3idd1$opj$>...

> Well I am trying to make Q a 3D matrix that has the value of F through each step of time (represented by h), so by looping through h I was attempting to fill the 3D matrix with the solution to F at each time point. I just don't understand why that causes an error.

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

Matt

unread,

Jul 15, 2009, 4:49:02 AM7/15/09

to

"Kevin " <> wrote in message <h3i3v3$rn6$>...

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.

matlab

U can see a part of my code in MATLAB. when i run it, i receive this error:
Assignment has more non-singleton rhs dimensions than non-singleton
subscripts.
please help me to correct it and know it's reasons. tnx a lot.

while Time < t_stop for i4 = 1:x for j4 = 1:y for k4 = 1:z % t1 has been defined in another place and updates in every cycle t2 = find(t1 ~= -1); %t2 is not empty because t1 has non-(-1) elements t3 = zeros(1,numel(t2)); for i5 = 1:numel(t2) t3(i5) = t1(t2(i5)); end; var1 = min(t3(:)); min_time(i4,j4,k4) = var1; if numel(find(t1 == var1)) == 1 min_IND (i4,j4,k4) = find(t1 == var1); else Temp_find = find(t1 == var1); min_IND (i4,j4,k4) = Temp_find(randi(numel(find(t1 == var1)))); end; t1 = zeros(1,41)-1; end; end; end; Time=Time+1; end;

Related Question

    Task has more non-singleton rhs measurements than non-singleton addendums task has more non-singleton rhs measurements than non-singleton addendums There are numerous inquiries regarding Assignment has more non-singleton rhs measurements than non-singleton addendums Answer : There is a task (giving an incentive to a variable, fundamentally when you use =) where the right-hand side (rhs, the incentive to be given to the variable that is on the lhs) is of another dimensionality than the lhs. The accompanying code delivers a similar mistake, yet in an all the more clear condition. a = zeros(5,1) ;%is 5 by 1; note that a has 1 singleton measurement (the subsequent one) b = zeros(5,5) ;% 5 by 5, no singleton measurement a(:,:) = b ; %error tossed here.

    Assignment has more non-singleton rhs dimensions than non-singleton subscripts