LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a 3D lookup table from CSV

Solved!
Go to solution

Sorry for that, I have now saved it as v16 file.

 

The problem is that my 3d Matrix  (named array in the VI) only seem to take in the first value while all other values only are NaNs.

0 Kudos
Message 11 of 40
(1,838 Views)

Either save 1 CSV for each Z, or use Rehape array to a 1D to write it to one file (and add some info about dimension sizes)

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 12 of 40
(1,841 Views)

@antje668 wrote:

Sorry for that, I have now saved it as v16 file.

 

The problem is that my 3d Matrix  (named array in the VI) only seem to take in the first value while all other values only are NaNs.


The problem is the autoindexing messing up the grid. It needs to be a single 1D array to work. In the current way you organized your files, it should work like so:

 

LLindenbauer_2-1654872225052.png

 

You can use "Highlight Execution" to see the program in action, so you can trace where the data is flowing and "Auto-Clean up Block Diagram" should work great on your VI to shorten the paths.

Message 13 of 40
(1,833 Views)

Since your gridlines are 1D, you should read them as 1D (and transposed) and not autoindex.

 

(Search array, is generally dangerous for DBLs. Since these are non-descending, I would use threshold array and round to nearest. It is also more efficient)

Message 14 of 40
(1,826 Views)
Solution
Accepted by antje668

See if this can give you some ideas (probably needs some tweaks):

 

altenbach_1-1654874779208.png

 

 

Notes:

 

  • "Replace array subset" operates in-place. The IPE just complicates things because you are not even interested in the existing element!
  • It is easier to auto-index over the 2D array, getting one row at a time.
  • the 2D array should probably be based on the sizes of the grids, not some diagram constants.
  • Many duplicate operations can be eliminated by using loops.
  • GridlinesZ has duplicate values!!! Make sure you use sufficient digits when writing it.
  • etc.
  •  
Message 15 of 40
(1,817 Views)

@altenbach wrote:

See if this can give you some ideas [...]


It certainly gave me some. Bundling/Unbundling arrays to prevent the autoindex from resizing the smaller ones into a large 2D-Array is something I'll gladly add to my toolset.

Message 16 of 40
(1,806 Views)

Firstly thank for a very nice and neat code which suits my task great. I do have some questions about it though.

 

  • the 2D array should probably be based on the sizes of the grids, not some diagram constants.

 

Could a solution be to just multiply the size of the three grids and have that as an input to "number of rows" in the read delimited spreadsheet VI?

 

 


 

  • GridlinesZ has duplicate values!!! Make sure you use sufficient digits when writing it.c.

I Noticed that now, you made it clear with the size indicator 🙂

 

I seem to get what i want from your code, the 3D matrix (named Array) is strucutred as I want.

 

The next step for me would now to use the 3D lookup table block, and for that I think I might need to split the X,Y,Z inputs into three different vectors? The LUT Data input to the LU table is already there (The 3D matrix named Array) However I tried to do so and got this error message: "The dimensions of the arrays of the lookup table are inconsistent" which I really dont understand how they could be?

0 Kudos
Message 17 of 40
(1,794 Views)

When you get an error, show us your code. We are not clairvoyant!

 

(You can use exactly the same code as I did do turn value triplets into 3D indices, then use index array instead of replace array subset to get that element.)

 

Be aware that "threshold array" will give you the nearest even if there is no exact match. You might want to test if the result is close enough to an integer to be valid.

 

You still need to either increase the resolution of your Z scale or eliminate the duplicate value.

0 Kudos
Message 18 of 40
(1,792 Views)

Sorry for that! 

 

Here is how my code looks like right now, I could not clearly grasp how to split up the vectors in the way you proposed, the index array output is a double and the shift registers takes in a 3D array. Maybe I misunderstood how to get it working with the index array.

 

I have attached the code I have right now with the 3D lookup table Vi from the simulation and control palette. I have also attached the new gridline file for Z values, without duplicates.

0 Kudos
Message 19 of 40
(1,768 Views)

Sorry, I don't have the simulation toolkit, but to look up a value using "index array", here's how you would do it.

 

altenbach_0-1654881414441.png

 

Message 20 of 40
(1,760 Views)