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: 

Multiply elements in an array

This is probably simple but it is bugging me like crazy. I need to multiply each element of an array by a formula node and dump the results into another array for plotting to a graph. Easy or hard??? Help !!! lol
Best regards and thanks... Franco
0 Kudos
Message 1 of 3
(6,780 Views)
Franco,

Sounds easy, but I am not sure. Try this.
- Feed the array (of whose elements you need to multiply) to a For loop (it gets auto-indexed, if not idex it).
- Multiply each element with the output of the formula node (which should be in the for loop or can be outside too, the output of the formula node can be fed to the for loop if outside).
- Then pull the output of the multiplication out of the FOR loop (which automatically becomes an array if the indexing is enabled) and then feed it further to the plot or what ever.

This should work. (FIND THE EXAMPLE ATTATCHED)
Good Luck and Have fun.

-Pari.
0 Kudos
Message 2 of 3
(6,780 Views)
Franco,
There are two solutions:

1. If the formula doesn't depend on the values of array you can simply multiply array and result of formula calculations:
Example:
A - array of double
F=sin(25)*arccos(32)
Result=A*F - array of double;
In this case just wire array and output of formula node to the mutiply function and you'll get the result as array.

2. The formula depends on values of array
Example:
A - array of double
F=sin(25)*arccos(A[i])
Result=A*F - array of double;
In this case you have to organize the For loop and multiply elements of array with results of formula calculations inside the loop. Dont forget to select 'Enable indexing" on input and output nodes of the loop for your arrays.

Oleg Chutko.
0 Kudos
Message 3 of 3
(6,780 Views)