Prev: Report Generator Batch
Next: Report Generator Book
From: Steven Lord on 15 Jul 2010 14:07 "Andy " <dcg48(a)cornell.edu> wrote in message news:i1n9g0$bft$1(a)fred.mathworks.com... > Hi, I am trying to optimize an equation in which I have a 3d matrix A of > size 64^3x15x7 which I wish to multiply by an unknown matrix B of size > 1x15x7 (I think), to equal a target matrix T of size 64^3x1. > I tried using the following but it couldn't take the inverse of A: > B=inv(A)*T > > I also tried using least squares: > B=inv(A'*A)*A'*T But the transpose didn't work. Neither INV nor transpose are defined for 3D arrays, and neither is matrix multiplication. Perhaps you should RESHAPE your arrays into matrices (2D) and then use the backslash operator to solve the system of equations? -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Matt J on 15 Jul 2010 14:20 "Andy " <dcg48(a)cornell.edu> wrote in message <i1ngu4$ecj$1(a)fred.mathworks.com>... > > Your description is very vague, but it sounds like you want > > > > B=reshape(A,64^3,[])\T; > > Matt, > This gives me an error message that the matrix dimensions must agree. > > What I am trying to do is the following: > I have a 64x64x64 matrix of a magnetic field, which I wish to replicate using a collection of individual magnetic pieces, located at different positions in a grid (15 columns by 7 rows) I created. > > I created a series of 64x64x64 matrices who each represent the field of one magnetic piece, located at a certain position on the grid, one matrix per position. To create matrix A, I reshaped each of these matrices down to 64^3x1 and concatenated them in the correct order to create a 64^3x15x7 matrix. > > T is a similarly reshaped matrix of my original magnetic field, from 64x64x64 to 64^3x1. > > What I wish to get from matrix B, is the number of pieces I need to put at each location in order to recreate my original field. ================== You need to specify more clearly the formula relating A,B, and T It would be clearest to post for us the formula for T(i) in terms of A(i,j,k) and B
From: Andy on 15 Jul 2010 14:31 "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <i1njgr$1p2 > You need to specify more clearly the formula relating A,B, and T A*b=T > It would be clearest to post for us the formula for T(i) in terms of A(i,j,k) and B I'm not sure the formula for T(i). T as a whole is the summation of A(:,j,k)*B(j,k) for all 15 columns (j) and 7 rows (k). Steven, I'm not sure if I'm missing something but I don't believe that will work for my situation (see above). Thanks
From: Matt J on 15 Jul 2010 14:53 "Andy " <dcg48(a)cornell.edu> wrote in message <i1nk5r$dla$1(a)fred.mathworks.com>... > > It would be clearest to post for us the formula for T(i) in terms of A(i,j,k) and B > I'm not sure the formula for T(i). T as a whole is the summation of A(:,j,k)*B(j,k) for all 15 columns (j) and 7 rows (k). ===== In that case, the first solution I gave you should have worked. I suggest you check the dimensions of A and T and post your full error messages.
From: Matt J on 15 Jul 2010 15:02
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <i1nleg$6di$1(a)fred.mathworks.com>... > "Andy " <dcg48(a)cornell.edu> wrote in message <i1nk5r$dla$1(a)fred.mathworks.com>... > > > > It would be clearest to post for us the formula for T(i) in terms of A(i,j,k) and B > > I'm not sure the formula for T(i). T as a whole is the summation of A(:,j,k)*B(j,k) for all 15 columns (j) and 7 rows (k). > ===== > > In that case, the first solution I gave you should have worked. I suggest you check the dimensions of A and T and post your full error messages. ================= Note, for example, how the following does not result in an error. If all the matrices have the dimensions you claim, there should be no problem. >> A=rand(64^3,15,7); T=rand(64^3,1); >> B=reshape(A,64^3,[])\T; whos B Name Size Bytes Class Attributes B 105x1 840 double |