From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to get multiprod working
Date: Sat, 22 Jan 2011 15:19:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 44
Message-ID: <ihesh7$l8f$>
References: <ihal0c$l8n$> <iham08$pjm$> <ihbppt$nl1$> <ihc5pk$o8u$> <ihddhg$hhd$> <ihdng9$jbp$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1295709543 21775 (22 Jan 2011 15:19:03 GMT)
NNTP-Posting-Date: Sat, 22 Jan 2011 15:19:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1037739
Xref: comp.soft-sys.matlab:705383

"James Tursa" wrote in message <ihdng9$jbp$>...
> "Jonathan W Smith" wrote in message <ihddhg$hhd$>...
> > 
> > I have 2 matrices A(6,6,4,24,28) and B(6,6,28)  I want to do the following A(6,6,1,1,1) x B(6,6,1) ... A(6,6,4,24,28) x B(6,6,28) but only when the 5th dimension of A and 3rd dimension of B match.
> C = mtimesx(A,reshape(B,6,6,1,1,28));
> > I was getting erroneous values for the elements in the 6x6 matrices when using multiprod.
> I am not familiar enough with multiprod to know the proper input dimensions needed to do the calculation you want in multiprod. Maybe the following will work:
> C = multiprod(A,reshape(B,6,6,1,1,28));
> > I do not have visual basic that allows me to use mtimesx.
> MTIMESX does not need Visual Basic, or anything from Visual Studio. It can be used by anyone with any C compiler that compiles mex routines, and that includes the lcc compiler that comes shipped with MATLAB. You can build MTIMESX on a Windows system as follows:
> - Download from the FEX (I assume you have already done this)
> - Copy the files to one of your directories that is on the MATLAB path (see Steve Lord's post).
> - Issue the following commands:
> mex -setup
> (Wait for the prompt, then press Enter)
> (Select a C/C++ compiler, such as lcc)
> mtimesx % This will cause mtimesx to self-build
> If you have a Mac or other Unix/Linux type system, the build routine is not automated. If that is the case let me know and I can try to help with this.
> James Tursa

James and all,

I got MEX to compile and mtimesx to work.   I tried the mtimesx suggestion above but it the elements of the 6x6 matrices continued to have the erroneous values.  Elements of the 6 x 6 matrices where the values should have been 0 were not.

Matrix B is a column with 28 levels of 6 x 6 matrices. I each level in B contains fractions.  I want to multiply these columns in B by A which for every hour (24) of everyday (4 days) has columns of 28 6 x 6 matrices.  

The elements of 6 x 6 matrices in A have unique values for every hour of everyday, however the 28 levels are the same.  When I multiply each of level in A by their corresponding level in B each hour and level in A, the values in A are adjusted based on the based on the fraction.