LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

creating 1d array of ellements

Solved!
Go to solution

At a point in my program I want to make a 1D array of arrayelements selected from a 2d array input.

When i run my program now you just get one ellement in my indicator, but I need to get all the elements stored in an array so I can work on whit this 1D array...

Vi will show my problem..

0 Kudos
Message 1 of 7
(3,498 Views)

(Posting by phone, cannot see your code)

 

To get a row or column from a 2D array, use "index array" with one index unwired.

0 Kudos
Message 2 of 7
(3,495 Views)

It looks like you're trying to get all the elements in each 3x3 section of the larger array?  Is that right?

Anyway, your reshape array (with size = row x column) after your array subset will give you all 9 elements.  I have no idea what you're trying to accomplish indexing index 5 from the array.  (indexing a 1d array is going to give you a scalar every time)

 

Aside: Why aren't you using auto indexing, instead of wiring 255 to N?  Why are you using 255 if your arrays are 256x256?

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 3 of 7
(3,485 Views)

use reshape array and # of elements for dimension size..in your case 2D of 255x255 and a 1D reshape of 65025 # of elements. you were almost there...i re modded your vi.1d_VI.png

Download All
0 Kudos
Message 4 of 7
(3,475 Views)

Seems you want to get a list of all medians from all 3x3 subsections.

 

First of all, your output array should probably be slightly smaller, because there are only 254 3x3 section in each dimensions.

 

Since you know the size of the final 1D array, you should initialize a 1D array of the correct size, then replace elements in the order they are generated. Here's a simple example (LV 2010):

 

Download All
0 Kudos
Message 5 of 7
(3,464 Views)
Solution
Accepted by topic author koekie

Note that my above code cannot be parallelized because the shift register configuration is not a know reduction.

 

Quote from "tools...find parallelizable loops": 

This For Loop is not safe to parallelize. Error(s):
- The iterations of the For Loop may depend on each other through Shift Registers, and the computation is not a recognized reduction.
- Multiple iterations of the For Loop may access the same array element, and at least one access may write to the element.

 

A simple change (see below) allows full parallelization of both loops (I only recommend to parallelize the outermost loop for obvious reasons ;)). This will speed up your code proportional to the number of CPU cores in your hardware.

 

 

0 Kudos
Message 6 of 7
(3,444 Views)

Indeed, I want to get the medians of the 3-3 array bloks of my input array.

I indeed also have a few other problems ready to solve in connection with the smaller sizes,..

Hopefully I will find them.

 

Great guys, my problem is temporarily solved, ready to move on!

Appreciate you quickly help!

0 Kudos
Message 7 of 7
(3,427 Views)