LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3D Array organization fomr a 1D array in a for loop

Solved!
Go to solution

Hello -

 

I'm currently using an NI program to open multiple files (http://zone.ni.com/devzone/cda/epd/p/id/818). As a side note, I have noticed the files are automatically organized by name after the files are returned from the sub-VI. The files I am loading will be named BxCy where x is a one digit and y is a two digit number (e.g., B2C34) and within each file I load is a 1D array which I extract.

 

What I would like to do is organize the output so it has the structure of

Page C1

Row B1 [(1D array)]

Row B2 [(1D array)]

...

Row Bn [(1D array)]

 

Page C2

Row B1 [(1D array)]

Row B2 [(1D array)]

...

Row Bn [(1D array)]

 

and so on.

 

My first issue is I am not 100% sure that the file names will be organized by name in the multi-file read VI so is there anyone who can verify this? Secondly Even with this I would like to know if there are any efficient methods for doing this. Should I just use two index arrays to file them in according to their B anc C numbers? This seems slow and I've seen on other posts that the reshape array function might quicken the process but am unsure of how to proceed. I also do not have access to inplace structures (I don't know if I just forgot to install this module or if it was not included in my LabVIEW subscription).

 

The program I attached is in LabVIEW 2009 SP1 and I'm on Windows 7 64-bit machine.

 

Thank you in advance!

J

Download All
0 Kudos
Message 1 of 5
(3,212 Views)
Solution
Accepted by topic author vandej

 

  • You did not include the subVIs. Please do.
  • Never convert a path to a string unless you are doing something OS specific. Use "strip path" and operate on the filename as strings, then convert back to a path using "build path" if needed.
  • To create a 3D array from 1D arrays, You need two stacked FOR loops. Loop over pages in the outer loop and over rows in the inner loop and outoindex at the output tunnels. You'll get a 3D array automatically.
  • It might be much easier to use "list files" with a pattern of "B*C*" for example. Is the page always 1 digit and the row number two digits (padded with a leading zero if needed)? In this case the sorting will be correct.

 

 

Message 2 of 5
(3,204 Views)

Sorry about not including the sub VI, should have but there are a half dozen SubVI's and I'd probably have to include a few data sets. I was just hoping someone would be able to point me in the right direction, which you did.

 

I modified the sub-VI's to take in a path instead of a string so I avoid converting and only use the strip path when I am looking for the "B*C**" numbers.

 

I do have the program working now using using two systems, organizing the data or organizing the filenames. I have attached these along with a dummy subVI if you have any additional comments/improvements to offer me but I plan on using the filename organization system. 

 

As for the "list files" function, I tried it out and it could be very helpful for what I'm doing but have not had a chance to incorporate it into the code, thanks for pointing this out though!

 

Thanks again,

J

 

Download All
0 Kudos
Message 3 of 5
(3,183 Views)

Do you have a simple list of typical filenames for testing? For example create an indicator after the first subVI and run your VI to populate it. Now disconnect the new indicator and right-click "change to constant". Save the VI and attach it once more.

 

Especially in the lower part you are seriously thrashing memory using delete from array followed by insert into array. A simple "replace array subset" would operate in place and would not cause constant reallocations. (You could even use the in place element" structure). Also the upper code could probably be significantly simplfied. Seems overly complicated.

0 Kudos
Message 4 of 5
(3,178 Views)

I know my method for structuing the array isn't the best method, but I wasn't sure how to go about appending new values or using the replace array subset to build up the array when I only have the cam number to keep track of just the rows but nothing for the columns. I can see how you can use a shift register to either build each cam array or keep tabs on the last column index but I thought this would add comlications to the code vs wasting memory when, at most, this array will be a few hundred filenames large.

 

I have attached my code with a set of a few example filenames set into the control. Hope the rest of my reply makes sense.

0 Kudos
Message 5 of 5
(3,169 Views)