Greetings to you all!
I have two matrices:
Matrix_W=[P,N]
Matrix_X=[4*P,N]
I want to perform a multiplication between the [i,j]-th elements of W and the
[4*i-3 : 4*i , j]-th ranges of elements of X.
and end up with a [4*P,N] matrix.
I there a way to quickly perform such an operation without having to endure the overkill of a double for-loop?
Thank you in advance.
|
|
0
|
|
|
|
Reply
|
George
|
5/26/2010 12:15:21 PM |
|
"George Antonopoulos" <georanto@gmail.com> wrote in message
news:htj3cp$har$1@fred.mathworks.com...
> Greetings to you all!
>
> I have two matrices:
> Matrix_W=[P,N]
> Matrix_X=[4*P,N]
>
> I want to perform a multiplication between the [i,j]-th elements of W and
> the [4*i-3 : 4*i , j]-th ranges of elements of X.
> and end up with a [4*P,N] matrix.
>
> I there a way to quickly perform such an operation without having to
> endure the overkill of a double for-loop?
Is this what you want?
>> x = [1 2 3;4 5 6];
>> y = rand(8, 3);
>> z = (kron(x, ones(4, 1)).*y)
If not, please post a SMALL example showing specific values for W and X and
what you want the resulting matrix to be.
--
Steve Lord
slord@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
|
|
0
|
|
|
|
Reply
|
Steven
|
5/26/2010 1:22:50 PM
|
|
Is this is what you want?
% Data
P=3;
N=2;
X=ceil(5*rand(4*P,N))
W=ceil(5*rand(P,N))
% Engine
Z=reshape(bsxfun(@times,reshape(W,[1 P N]),reshape(X,[4 P N])),[4*P N])
% Bruno
|
|
0
|
|
|
|
Reply
|
Bruno
|
5/26/2010 1:36:04 PM
|
|
Both versions seem to provide the result that I need.
I will study them further to see how they work. I had a suspicion
that a kronecker product is involved somewhere.
I thank you for your answers both.
|
|
0
|
|
|
|
Reply
|
George
|
5/26/2010 2:06:04 PM
|
|
|
3 Replies
331 Views
(page loaded in 0.044 seconds)
Similiar Articles: Matrix element to Matrix element-range mutiplication - comp.soft ...Greetings to you all! I have two matrices: Matrix_W=[P,N] Matrix_X=[4*P,N] I want to perform a multiplication between the [i,j]-th elements of... element-by-element multiplication - comp.soft-sys.matlab ...Matrix element to Matrix element-range mutiplication - comp.soft ... Greetings to you all! I have two matrices: Matrix_W=[P,N] Matrix_X=[4*P,N] I want to perform a ... find and replace elements of a matrix? - comp.soft-sys.matlab ...Matrix element to Matrix element-range mutiplication - comp.soft ... find and replace elements of a matrix? - comp.soft-sys.matlab ... Matrix element to Matrix element ... Grouping the Nonzero Elements of an NxNxN Matrix - comp.soft-sys ...Matrix element to Matrix element-range mutiplication - comp.soft ... Grouping the Nonzero Elements of an NxNxN Matrix - comp.soft-sys ... Matrix element to Matrix element ... Finding n largest values in a matrix - comp.soft-sys.matlab ...Matrix element to Matrix element-range mutiplication - comp.soft ... Finding n largest values in a matrix - comp.soft-sys.matlab ..... be bigger (1024x1024) and this ... Help with Summing the elements in an array - comp.soft-sys.matlab ...Matrix element to Matrix element-range mutiplication - comp.soft ... Help with Summing the elements in an array - comp.soft-sys.matlab ... On Sat, 25 Sep 2010 21:12:04 ... Converting an Image array to Vector or Matrix - comp.soft-sys ...Matrix element to Matrix element-range mutiplication - comp.soft ... Converting an Image array to Vector or Matrix - comp.soft-sys ... I want to convert the elements into ... matrix multiplication - comp.graphics.api.openglMatrix element to Matrix element-range mutiplication - comp.soft ... Greetings to you all! I have two matrices: Matrix_W=[P,N] Matrix_X=[4*P,N] I want to perform a ... Changing multiple matrix element at one time - comp.soft-sys ...Hey, I'm trying to modify multiple matrix's elements at a time ... element-by-element multiplication - comp.soft-sys.matlab ... Changing multiple matrix element ... IML: matrix product with missing elements. - comp.soft-sys.sas ...... then you could probably write a program to accomplish you new "matrix multiplication ... with SAS PROC IML... or ||) is used to indicate the position of elements of a matrix. Matrix element to Matrix element-range mutiplication - comp.soft ...Greetings to you all! I have two matrices: Matrix_W=[P,N] Matrix_X=[4*P,N] I want to perform a multiplication between the [i,j]-th elements of... Element-By-Element Multiplication - O-Matrix: High Performance ...Description Element-by-element multiplication of two values that are integer, real, double-precision, or complex. (One, but not both, of the values may be logical.) 7/23/2012 9:57:31 PM
|