11-01-2006 01:58 AM
11-01-2006 02:10 AM
11-01-2006 02:38 AM - edited 11-01-2006 02:38 AM
What are your requirements?
Other possible intepretations are e.g.: average all rows (or columns) of the 2D array to yield a 1D array.
Message Edited by altenbach on 11-01-2006 12:41 AM
04-17-2009 04:33 PM
Hello All!
I have a similar problem with arrays. My problem is:
I have a 2D array(size 5X8) called message and a 1D array(size 4) called input 1D array. My application requires that I multiply evry element in the 2D array with the whole(all elements of 1D array). As you can see in the picture attached, I have two for loops auto indexed on the rows and colums of the 2D array respectively. I pass in the 1D array in to the inside for loop without auto indexing. This works fine. However, the problem is that at the output . Every time it multiplies an element (of 2D array)with the 1D array, it goes to a new row, where as I want it to continue in the same row until it reaches to the end of that particular row in the 2D array.
For example, to make it clear: say message = 1 0 1 1 1 0 1 1
1 0 0 0 1 0 1 0
and 1D input array = [100 200 100 500]
Then I need the output array = 100 200 100 500 0 0 0 0 100 200 100 500 100 200 100 500 100 200 100 500 0 0 0 0 100 200 100 500 100 200 100 500
100 200 100 500 0 0 0 0 0 0 0 0 0 0 0 0 100 200 100 500 0 0 0 0 100 200 100 500 0 0 0 0
How ever, LabView gives: 100 200 100 500
0 0 0 0
100 200 100 500
100 200 100 500
100 200 100 500
0 0 0 0
100 200 100 500
100 200 100 500
How can I fix this? Im really stuck. Any help would be really appreciated!!!
04-17-2009 04:42 PM - edited 04-17-2009 04:45 PM
Hi LSASS,
have you read Altenbachs message just before adding your question? Then the picture he included should give you all you need: just reshape your 2d result to a 1d array (it will append all the rows into just one row)...
But you may also use a shift register and a "build array" to get your 1d array - decide what is easier to you...
04-17-2009 04:46 PM
Actually, he's trying to go from a 3D array to a 2D array, but the concept is the same. You just have to give it the right number of rows and columns:
04-17-2009 04:51 PM
04-17-2009 05:01 PM
GerdW wrote:Hi smercurio,
in the text he gives examples of 2d and 1d...
Yes, but in the screenshot he has a 3D array. I was confused at first as well until I realized he was showing just one page of the 3D array in the body of the message.
04-17-2009 05:53 PM
HI smercurio and GerdW,
Thanks very much for the help. I just used the solution given to altenbach's problem in the previous post in my outer loop. that worked just fine. Also, using smercurio's suggestion also worked for me.
My problem is solved...Thanks again:)