Siri Posted April 11, 2009 Report Share Posted April 11, 2009 Hello everyone!! Im new to labview.. so i hav heaps of questions. I hav a 2D array and I need to add another 1D array to all the rows of this 2D array. Note: the no of colums of the 1D array and 2D array are the same. I tried using the index array function inside a for loop.. but it does not fetch one row at a time.. so Im kinda stuck.. need help THanks in advance Quote Link to comment
santi122 Posted April 11, 2009 Report Share Posted April 11, 2009 Hi Siri, try the "Build Array" function from the Array functions ! I Think this will help you... greetz chris Quote Link to comment
Jolt Posted April 11, 2009 Report Share Posted April 11, 2009 Siri, I think you are asking to take every row in Array A and add Array B to get a row in Array C with that row defined as C1 = A1 + B1....Cn = An + Bn. If this is the case: One of the most straight-forward ways to do is to put Array A and B outside of a For loop (do not wire anything to the "N" of the loop). Wire A and B to the left edge of the loop. Right click each "tunnel" and select "Enable Indexing" for Array A and "Disable Indexing" for array B. Inside the loop use the numeric "add" for the two inputs and wire the output to the right edge of the loop. Select "Enable Indexing" to the output, create an indicator outside the loop and see the results! Have fun, Quote Link to comment
asbo Posted April 11, 2009 Report Share Posted April 11, 2009 QUOTE (Jolt @ Apr 10 2009, 07:31 AM) One of the most straight-forward ways to do is to put Array A and B outside of a For loop (do not wire anything to the "N" of the loop).Wire A and B to the left edge of the loop. Right click each "tunnel" and select "Enable Indexing" for Array A and "Disable Indexing" for array B. Inside the loop use the numeric "add" for the two inputs and wire the output to the right edge of the loop. Select "Enable Indexing" to the output, creat a indicator outside the loop and see the results! Actually, you don't need the for loop at all: just use Index Array to separate Array A and Array B then use the Add primitive to add Array C to either of them. Quote Link to comment
Jolt Posted April 11, 2009 Report Share Posted April 11, 2009 QUOTE (asbo @ Apr 10 2009, 08:13 AM) Actually, you don't need the for loop at all: just use Index Array to separate Array A and Array B then use the Add primitive to add Array C to either of them. asbo may be correct, it depends on what exactly you are trying to do - The loop in the answer above is only necessary if you are trying to add a 1-d "Array B" to every row of 2-D "Array A." There are, of course, many other ways to do this very thing but the auto-indexing For loop is a good place to start. The indexed loop also allows any number of rows in Array A - all will be processed. If none of these answers make sense please clarify the behavior you are looking for... Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.