# Thread Subject: Calculting incomplete convolution

 Subject: Calculting incomplete convolution From: Stefan Hovens Date: 22 Jan, 2009 22:20:21 Message: 1 of 6 I want to write the following program in Matlab, because excel can cope anymore Given: Matrix A consisting of 20 columns and 2000 rows which will not change Matrix B consisting of 200 columns and one row which will not change Matrix C consisting of 1 colmn and 2000 rows which will change Created during program : Matrix D consisting of 1 column of 2000 rows which will change Look up the element x (1 to 2000) in matrix A and remeber the row as y and the colmn as z Multiply the element in colmn y in Matrix B with the element in row z in Matrix C and add it to a new Matrix D in row x. When the element x is present more than once in matrix A than add it to the value that is already created in Matrix D. For x<1 add the value for Matrix D in row of x=1 For x>2000 add the value for matrix D in row of x=2000 Compare values of Matrix C with those of Matrix D, when the difference is less then p store Matrix D, else store Matrix D as Matrix C and start over again. This is a problem of an incomplete convolution. It can be written down much shorter, but I'm not able to do that YET.
 Subject: Calculting incomplete convolution From: Roger Stafford Date: 22 Jan, 2009 23:09:02 Message: 2 of 6 "Stefan Hovens" wrote in message ... > I want to write the following program in Matlab, because excel can cope anymore > > Given: > Matrix A consisting of 20 columns and 2000 rows which will not change > Matrix B consisting of 200 columns and one row which will not change > Matrix C consisting of 1 colmn and 2000 rows which will change > > Created during program : > Matrix D consisting of 1 column of 2000 rows which will change > > Look up the element x (1 to 2000) in matrix A and remeber the row as y and the colmn as z > Multiply the element in colmn y in Matrix B with the element in row z in Matrix C and add it to a new Matrix D in row x. When the element x is present more than once in matrix A than add it to the value that is already created in Matrix D. > For x<1 add the value for Matrix D in row of x=1 > For x>2000 add the value for matrix D in row of x=2000 > > Compare values of Matrix C with those of Matrix D, when the difference is less then p store Matrix D, else store Matrix D as Matrix C and start over again. > > This is a problem of an incomplete convolution. It can be written down much shorter, but I'm not able to do that YET.   Your wordage would imply that there are as many rows in A as there are columns in B, and as many columns in A as there are rows in C, but neither fact is true as you have described the sizes of A, B, and C. Assuming this is somehow repaired, it looks as though you have something that 'accumarray' could handle quite easily in computing D.   A and D are not of the same sizes. What do you mean by their "difference" being less than p? Roger Stafford
 Subject: Calculting incomplete convolution From: Roger Stafford Date: 22 Jan, 2009 23:18:02 Message: 3 of 6 "Roger Stafford" wrote in message ... > ...... > A and D are not of the same sizes. What do you mean by their "difference" being less than p? > ......   My last question was misstated. I should have asked what you meant by the difference between C and D being less than p? Did you mean maximum absolute difference, norm of difference, what? Roger Stafford
 Subject: Calculting incomplete convolution From: Stefan Hovens Date: 17 Feb, 2009 16:45:03 Message: 4 of 6 "Roger Stafford" wrote in message ... > "Roger Stafford" wrote in message ... > > ...... > > A and D are not of the same sizes. What do you mean by their "difference" being less than p? > > ...... > > My last question was misstated. I should have asked what you meant by the difference between C and D being less than p? Did you mean maximum absolute difference, norm of difference, what? > > Roger Stafford He Roger, Sorry for my late comment, I was on holiday. It's true the Matrix A consists of 200 instead of 20 columns. The difference p will be the absolute difference between the two matrices. I've got the whole problem in a Word doc and PDF, but I'm not able to post it on this forum. Stefan
 Subject: Calculting incomplete convolution From: Roger Stafford Date: 17 Feb, 2009 22:24:02 Message: 5 of 6 "Stefan Hovens" wrote in message ... > ....... > Sorry for my late comment, I was on holiday. > It's true the Matrix A consists of 200 instead of 20 columns. > The difference p will be the absolute difference between the two matrices. > I've got the whole problem in a Word doc and PDF, but I'm not able to post it on this forum. > .......   You still seem to have the numbers mixed up, Stefan. You need to make some change like this: [Look up the element x (1 to 2000) in matrix A and remeber the column as y and the row as z]. This way the range of row indices in A will match the number of rows in C and the range of column indices in A will match the number of columns in B. One way or another there has to be a change.   Also I still don't understand what you want to do when you say "Compare values of Matrix C with those of Matrix D, when the difference is less then p store Matrix D, else store Matrix D as Matrix C and start over again." You will have to clarify that considerably.   As I advised you back in January, you can use 'accumarray' for your addition process.  m = 2000; n = 200; m2 = 2000;  [Z,Y] = ndgrid(1:m,1:n);  X = max(min(A(Z,Y),m2),1);  CB = C*B;  D = accumarray(X(:),CB(:),[m2,1]); For this to work, all numbers in A need to be integers. Roger Stafford
 Subject: Calculting incomplete convolution From: Roger Stafford Date: 18 Feb, 2009 00:19:01 Message: 6 of 6 "Roger Stafford" wrote in message ... > ...... > You still seem to have the numbers mixed up, Stefan. > ...... > m = 2000; n = 200; m2 = 2000; > [Z,Y] = ndgrid(1:m,1:n); > X = max(min(A(Z,Y),m2),1); > CB = C*B; > D = accumarray(X(:),CB(:),[m2,1]); > ......   You aren't the only one making mistakes, Stefan. I need to correct that code I sent a little while ago. Using 'ndgrid' was a big mistake. It's easier than that. It should read:  m = 2000; n = 200; m2 = 2000;  A1 = max(min(A,m2),1);  CB = C*B;  D = accumarray(A1(:),CB(:),[m2,1]); The array sizes are: A - mxn, B - 1xn, C - mx1, D - m2x1 and presumably you want to have m2 = m.   Based on what you stated earlier in, "start over again", the above needs to be repeated with altered C until the given condition "the difference is less then p" is satisfied. Roger Stafford

Separated by commas
Ex.: root locus, bode

### What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.