Prev: Report Generator Batch
Next: Report Generator Book
From: Andy on 15 Jul 2010 11:29 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. My background in linear algebra is very limited to 2d matrices so I'd appreciate any help to solve my problem. I'm looking into using the optimization tool box but can't quite figure out how to convert my equation into any of the forms in the examples. Thanks!
From: Jan Simon on 15 Jul 2010 12:15 Dear Andy, > 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. Instead of writing "didn't work" and "couldn't take", you should post -and most of all- read the appearing error messages. In all cases I've seen in the last 12 years, Matlab's error messages are very helpful (except if trying a "reshape(1, [-1, -1])" in older versions). Kind regards, Jan
From: Andy on 15 Jul 2010 13:01 Jan, My appologies, here are the error messages I recieved: > > B=inv(A)*T ??? Undefined function or method 'inv' for input artuments of type 'double' and attributes 'full 3d real' > > I also tried using least squares: > > B=inv(A'*A)*A'*T ??? Error using ==> cttranspose Transpose on ND array is not defined. Thank you
From: Matt J on 15 Jul 2010 13:12 "Andy " <dcg48(a)cornell.edu> wrote in message <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. ====== Your description is very vague, but it sounds like you want B=reshape(A,64^3,[])\T;
From: Andy on 15 Jul 2010 13:36
> 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. Hope this helps, Andy |