From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sum of Vector Scalar Product

So i had a problem. Two Matrices A and B.I had to multiply the first row of A with the last column of B element with element.(I attached a picture of it).Now i have to sum the products( scalar product of vectors ). Any ideeas? 

0 Kudos
Message 1 of 8
(2,955 Views)

The Full Problem is this :  A and B are two square matrices; multiply first row of A with last column of B element by element and sum their products( scalar product of two vectors). 

0 Kudos
Message 2 of 8
(2,947 Views)

Did you read gregoryj's advice for your previous thread (here) that you marked as a solution? Have you tried typing ctrl+space to bring up the quick drop window and type in the function you need? I'll give you a hint, type "add" (not sum) and look at the list of available functions . Read the help for each of those functions and see if one of them will work for you.

Take gregoryj's other advice and go through the FREE training that is available online.

0 Kudos
Message 3 of 8
(2,933 Views)

Just realized it's not easy to get help for functions while using quick drop. If you Show Context Help (type ctrl-H) and hover the mouse over a function in the palette, it will show a brief explanation of the function. You can click the Detailed Help for more info.

Hint: The function you are looking for is in the Numeric palette

 

context help.png

0 Kudos
Message 4 of 8
(2,925 Views)

I think i figured it out, not sure if it's good, could you take a look?

0 Kudos
Message 5 of 8
(2,922 Views)

Why don't you use Add Array Elements?

0 Kudos
Message 6 of 8
(2,913 Views)

If you attached code instead of a picture, it would be much easier for us to show you a counter-example that would totally fail (and, I hope, you'd learn something from the experience).  Here's a hint at the problem -- how do you define "first" and "last" when talking about a 2D array?  Another question for you -- you specified that A and B are matrices, not arrays.  Are you aware (depending, of course, on the version of LabVIEW you are using) that LabVIEW has a Matrix type?  [Don't worry -- a little bit of studying, reading the LabVIEW Help, paying attention in class, asking your Instructor, etc. should easily get you past this minor difficulty ...].

 

Bob Schor

0 Kudos
Message 7 of 8
(2,897 Views)

@Marius56 wrote:

I think i figured it out, not sure if it's good, could you take a look?


  • No, it is not good yet.
  • You have 2D arrays, not matrices (there is a diffference in LabVIEW). Matrices are useful if you do linear algebra, but you don't so continue using 2D arrays.
  • As I already said in your duplicate old thread, the index of the "last" column depends on the total number of columns and thus cannot be a constant. Fortunately, it is easy calculate the correct column index. Try it!
  • There is nor reason to introduce right-to-left wires, so don't do that.
  • Don't call the thread "Sum of vector scalar product", because the scalar product of a row and column vector already includes the sum in the definition (scalar product is the same as dot product!).
  • mind your representations (e.g. blue vs orange). There is absolutely no need for coercion dots here.
  • As others have said, there is a function to add all elements of an array. No loop needed.
  • LabVIEW even has the "dot product" which does the multiply&sum for you and even gives a potentially useful error if the input arrays differ in size, while a plain multiply would use the length of the smaller array and drop the remaining elements without telling you. (note that LabVIEW has no concept of row vs column vector when represented as 1D array, and there is no need for that)

Dotproduct.png

0 Kudos
Message 8 of 8
(2,889 Views)