LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

element-wise matrix multiplication/product (Hadamard product)

Is there really no operator for this in LabView? or am I blind?

 

Using the standard "multiplication", like A*B, labview performs AxB. But I want element wise multiplication, like if when you multiply two 2D arrays together.

 

The element wise matrix multiplication is called for the Hadamard product.

 

(and yes, you can code it yourself, but I just cant find to seem any operator for it, just want to know if I am blind or not!)

0 Kudos
Message 1 of 6
(9,539 Views)

You could try converting to arrays, multiplying and converting back to matrices. Not the ideal answer, I know.

0 Kudos
Message 2 of 6
(9,523 Views)

Hi,

 

Using the regular Multiply function should give you the per-element multiplication. Please view this KB for an example on matrix multiplication: http://digital.ni.com/public.nsf/allkb/862567530005F09C862566F400818DC0

 

A snippet of the file is attached below:

Matrix Multiplication.png

 

Kind regards,

Robert P-F
Applications Engineer
National Instruments
Message 3 of 6
(9,421 Views)

This does not work however if the input is a matrix (RealMatrix.ctl). In that case, the multiplication is not elementwise but performs matrix multiplication instead. So far, using a formula is the only workaround I figured out. Any ideas?

0 Kudos
Message 4 of 6
(9,113 Views)

You can convert the matrix to a 2D array before the multiplication. this is just a very cheap typedef change and is done in place.

0 Kudos
Message 5 of 6
(9,092 Views)

Thanks. Yes, in fact, converting the matrix to a 2D array and then using the multiplication is almost twice as fast as multiplying matrices using formulas.

0 Kudos
Message 6 of 6
(9,074 Views)