LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiplying elements of two different arrays

hey, I have a while loop thats performing two separate operations similtaneously and filling the data elements of two different 1d arrays with data.with each iteration of the loop a new value pass from an operation to an array.
I need to multipy to corresponding elements of the arrays such the first element of one array is skipped. so element i0 * element j1 , element i1 * elemnent j2 etc. how can i acess the elements and make the calculations? arrays could have hundreds of elements.
Thanks.
Brendan
0 Kudos
Message 1 of 6
(4,134 Views)
Just a thought...

Remove the first element out of array one (i0) and then do the multiply by wiring both arrays to the standard multiply.
See example below...

You may have to make both arrays the same size for this to work but im sure you get the general idea

Message Edited by Chaos on 05-17-2005 03:24 PM

0 Kudos
Message 2 of 6
(4,124 Views)
It would definitely be better to multiply the arrays outside the loop (much less strain on the CPU), but if you need the result of the multiplication inside the loop you can use a shift register to store the value of i0 when you're reading j1.

___________________
Try to take over the world!
0 Kudos
Message 3 of 6
(4,100 Views)
Hi,

I've made a VI up which detects if the arrays are the same size and pads the smaller one with 0's if need be. Therefore this should do pretty much what you need.

Let me know if you have any further problems.

Best regards,

Peter H.
Applications Engineer.
NIUK.
0 Kudos
Message 4 of 6
(4,080 Views)
hi Peter,

I have an array of 2.000.000 values (each long int). I need to do an "Moving average" operation which would than:

1) takes average of the first 10 values , plots it
2) remove the first value ,add 11.th value, take average, plots it in the next 100 ms in the chart
3) remove the first value, add 12.th value, take average, plots it in the next 100 ms in the chart

(as you see , it is a kind of shifting) the averaged array elements is always 10 , and after averaging those 10 elements , plot it with 100 ms distance in the graph.
....
....
....
....
1999989)  remove the 1.999.989 th element , add the last element

you have a possible idea ?

your help will be tremendously appreciated.
Regards

Silver
0 Kudos
Message 5 of 6
(3,879 Views)


blue silver wrote:
hi Peter,

I have an array of 2,000,000 values (each long int). I need to do an "Moving average" operation which would than:

1) takes average of the first 10 values , plots it
2) remove the first value ,add 11.th value, take average, plots it in the next 100 ms in the chart
3) remove the first value, add 12.th value, take average, plots it in the next 100 ms in the chart

(as you see , it is a kind of shifting) the averaged array elements is always 10 , and after averaging those 10 elements , plot it with 100 ms distance in the graph.
....
....
....
....
1999989)  remove the 1,999,989 th element , add the last element

you have a possible idea ?

your help will be tremendously appreciated.
Regards

Silver


Try this.  It iterates 10 times taking a subset of the array each time to sum it to a shift register.  When done, divides by the total number of iterations.  So it adds i0 to i1 to i2 to i3 to i{N}.  For each element from i0 up.  It will give you an array where n elements are missing  (because elements 0 through n-1 don't have N samples to average to.



Message Edited by Ravens Fan on 11-26-2007 09:26 PM
Message 6 of 6
(3,869 Views)