LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Quick sanity check when using 3D arrays

Solved!
Go to solution

Greetings NI community,

 

   I'm doing a quick sanity check to see if I'm on the right page when using 3D arrays (see attached document for array specifics).

 

   I coded up the Word document in LabVIEW (VI attached), and I have 2 sets of embedded for loops for each transformation - one to perform the transformation, and the other to switch it back to see if I get the same result.

 

 So for instance, if I feed in 3D array ABC, the first set of for loops will change it to BAC, and the second set should change it back to ABC to check if you did it right.

 

  Well, the first set is ok. But when I try and transform to CAB and BCA and check my work by switching it back, it doesn't switch back properly.

 


   I've checked this over and over again, and ran through the tutorials.

 

  Any help? If I am doing something wrong, can someone let me know what it is? I'd like to learn!

 

   Thanks!
   TheLT

                       

Download All
0 Kudos
Message 1 of 15
(3,611 Views)

You have an array in three dimensions, but ABC is just a linear set of three characters. It is not clear to me how the two definitions relate. You need to be much more detailed. What is the size in each dimension of the 3D array?

 

Can you please enter some typical data in the ABC array, make the current values the default, then save under a new name and attach it again. Also let us know what kind of result you expect after transformation.

Message 2 of 15
(3,599 Views)

altenbach,

 

   Ah, I see one of the problems. I thought that once I typed in the values and ran the program and saved it, I thought it would hold on to the numbers in the 3D array. Turns out once again I was wrong!

 

   Let me fix it and I will repost - apologies on that.

 

    Thanks!

    TheLT

0 Kudos
Message 3 of 15
(3,582 Views)

altenbach,

 

  Apologies on the late reply,

 

   Ok, I did add values to the 3D array I originally sent. Upon discovering that they aren't stored when you close and reopen them, I tried to make the current values as default from the front panel per your suggestion. Unfortunately, that didn't work either. Am I doing something wrong?

 

  What I did do, for time being, is make the 3D array a constant so that can show you what I am trying to do. The constant has the same thing as the array would have until I figure out the default value problem as described above. I checked the help - www.ni.com/gettingstarted/labviewbasics/datastructures.htm#Arrays
 - but I didn't see how to store values in the array and have them remain the same when you reopen the program.

 

   So, my 2 problems are -

 

   1.) Am I doing the 3D transforms right per the document (i.e, ABC -> BAC, ABC -> CAB, etc.)? I know I have the first one, but the last two I think I may be off.


   2.) How do I store values in the array so that when that VI open and closes the values are still stored?

 

   The updated code (where I made the array a constant) is attached.

  

   Thanks!
    TheLT

0 Kudos
Message 4 of 15
(3,570 Views)

To make your data in controls persistent, right-click on control:

 

defaults.png

 

Then save your VI. You can also do this with your entire front panel objects from under the Edit menu.

Message 5 of 15
(3,567 Views)

Hey Bill,

 

   Thanks for the reply - I did try doing the same exact thing and saved it, but it didn't work.

 

   I will try again, but for now I left it as a constant.

 

   Thanks!

    TheLT

0 Kudos
Message 6 of 15
(3,560 Views)

Bill,

 


   Ok, weird, but I think it work - updated code attached!

 

   So, my last problem is, am I doing the transforms right? ABC -> BAC, ABC -> CAB, and ABC->BCA? I'm sure I got the first one - the last two, meh.

 

   Thanks!

    TheLT

0 Kudos
Message 7 of 15
(3,558 Views)

TheLT wrote:

   So, my last problem is, am I doing the transforms right? ABC -> BAC, ABC -> CAB, and ABC->BCA? I'm sure I got the first one - the last two, meh.


(Make sure to ignore the above offtopic post, see also)

 

I still don't understand your ABC nomenclature. Can you fill the original array with a pattern that does not have any repeating elements. Currently, there is way too much ambiguity. Also, your dimensions are not the same in all directions, so your indexing will try to grab elements that are not actually threre.

Message 8 of 15
(3,540 Views)

altenbach,

 

   Don't worry - I won't respond to the poster before you. Side note, I've actually received a spam private message - is there any way to report that, and the above user?

 

   Sorry about the nomenclature. A is the "marker" or "page", B is the row, and C is the column. Apologies on my end for not specifying that. So, that document that was attached has 3 "pages" - A[0], A[1], and A[2], where A[0] had one column of 1's and another column of 2's.
 

   Not trying to belittle you, but just trying to make an attempt to make things clearer! I'm just trying to follow the document to a tee, and the VI was my attempt at it.

 

  I'm going to PM you as well.

 

   Thanks!

    TheLT

 

   

0 Kudos
Message 9 of 15
(3,525 Views)

No problem, now the problem makes more sense. Apparently you are looking for a 3D equivalent of the 2D transpose operation.

 

 

Message 10 of 15
(3,521 Views)