01-18-2017 04:57 AM
Hi guys,
Is there any way to combine two 2D arrays to get new one with corresponding elements added?
I mean like matrix addition in mathematics:
Thanks!
Solved! Go to Solution.
01-18-2017 05:07 AM
Just Add them!
01-18-2017 05:07 AM
Add should work.
/Y
01-18-2017 05:19 AM
It worked, funny. Did not think about simply adding them. But there is another idea, which would maybe make addition unnecessary:
If let's say I have 2 for loops, one is inside of the other. And I initialize an array full of zeroes outside both of them. Then, first(outer loop) fills some spaces in my array with values, after that the second loop(inner loop) fills some other spaces with values-in the end after both loops have finished, wouldn't my values end up in one array if my "Replace Array subset" functions are connected with shift registers?
01-18-2017 06:40 AM
mazhius wrote:If let's say I have 2 for loops, one is inside of the other. And I initialize an array full of zeroes outside both of them. Then, first(outer loop) fills some spaces in my array with values, after that the second loop(inner loop) fills some other spaces with values-in the end after both loops have finished, wouldn't my values end up in one array if my "Replace Array subset" functions are connected with shift registers?
What is your goal with this logic? This does not sound like a simple "Adding".
01-18-2017 06:46 AM
What is it you really want to do? Create a 2D/Matrix of random numbers? This is a simple way.
/Y
01-18-2017 06:49 AM
OR, an alternative interpretation of your question: If you have 2 nested loops with (the normal) autoindexing outputs, you'll get a 2D array as output. With Replace array you'll a part of your array with this "chunk" of 2D data.
If you r-click the loops output you can change to concatenating and/or conditional to get it as 1D array, in which case you'll replace 1 row or column.
/Y
01-20-2017 01:54 AM
Well my goal was to write a program(it's pretty much the first time for me working with labview) which would move my detector using two controllers along X and Y axes and scan the the whole area. Let's say if my area is 3x3 sized, then outer loop(green arrow) moves my detector along X axis, scans a value and writes it to an array. Then other two points in the same column would be scanned by inner loop(blue arrow) and saved into another array and added to the first one later, OR would be saved into the same array using shift registers. That was an idea.
Anyway, for now I decided to stick with a slower scan a column>back to start>scan another column algorithm, because first one takes more time for now and right now it's still worth to use slower algorithm to do the work. Thanks!