LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to multiply consecutive elements in an input array and produce an output array

how to multiply consecutive elements in an input array and produce an output array?

0 Kudos
Message 1 of 9
(3,331 Views)

You need to give more details than that.  What elements are we multiplying?  What should the output array be?  It would help if you supplied a good example.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 9
(3,305 Views)

Example:

N consecutive numbers where N=100

input array :12345.......100

output array: (1*2)(2*3)(3*4)...

           that is, 2 6 12 ... 

0 Kudos
Message 3 of 9
(3,299 Views)

So the output array should be one shorter?

 

Take " array subset" with index 1 and multiply the resulting array with the original array.

No loop needed. Try it!

Message 4 of 9
(3,286 Views)

Yes,

 

What is the input to the subarray and how do you create an original array of N consecutive elements?

 

I'm new to labview. Can you please show it here?

0 Kudos
Message 5 of 9
(3,251 Views)

Altenbach just gave the you the full answer in two functions (very impressive).  Look in the Array palette for Array Subset.  This is how you can create a subarray.  What was suggested to you was to wire in a 1 to the index and leave the length unwired.  The result will then be (based on your example) 2,3,4,5...100.  Multiply this array with your original array and you will have the result you are looking for.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 9
(3,218 Views)

The input to the subarray is the original array. Just branch the wire.

 

To create an array of consecutive integers 1..100, use a FOR loop. Wire 100 to N (right-click...create constant).

 

Place a "+1" (increment) inside the FOR loop and wire its input to the iteration terminal. wire its output to the right loop boundary. The output of the loop will be the desired array that you can manipulate as described (right-click...create indicator" to see it).

0 Kudos
Message 7 of 9
(3,205 Views)

Here's how the final code shouold look like...

 

I hope it will give you some initial clues how easy and powerful LabVIEW is and encourage you to learn more! Good luck!

 

 

 

Try to wire it up yourself and verify the output for correctness. 😉

0 Kudos
Message 8 of 9
(3,186 Views)

If this is homework you should also be able to do it by indexing in a loop and/or using shift registers in a loop.  Altenbach's method is elegant and efficient but would probably make a teacher suspicious if a beginner student handed it in. Smiley Wink

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 9 of 9
(3,169 Views)