LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Import Text File To Interpolated 3D Surface

Solved!
Go to solution

Hi all,

 

I've been trying to use a VI referenced by @chrisjfrye in this thread https://forums.ni.com/t5/LabVIEW/How-to-plot-3D-surface-graph-from-X-Y-Z-points/td-p/1193853/page/4

but I'm running into a bit of difficulty. I'm attempting to import 130 cell x 130 cell text file but the interpolated image isn't coming out as expected - I fear it may be something very simple that I'm just not grasping. I've given some of the text files that I'm attempting to demonstrate (one with 1 values surrounded by NaN, one with 1 values surrounded by 0s, and one with randomized values surrounded by 0s).

 

Thank you for your assistance in advance.

0 Kudos
Message 1 of 13
(1,810 Views)

@Linty_C wrote:

Hi all,

 

 I'm running into a bit of difficulty. I'm attempting to import 130 cell x 130 cell text file...


Show what you have tried and some one might be able to help.

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 Kudos
Message 2 of 13
(1,799 Views)

I've tried as follows:

  1. Changing the index values on all three 'index array functions.
    • This changes the graph, but it is still not what I am expecting. Changing any of the values to 130 gives a flat purple (lowest possible) surface.
  2. Changing P, Rx, and Ry indicator values.
    • I haven't noticed any difference in the graph when changing these values.
  3. Changing the sampling rate going into the 'Ramp Pattern VI.
    • Increasing this number increases the 'smoothness' of the graph
  4. Changing the 3D Plot properties.
    • i.e. changing x-axis, y-axis, and z-axis thresholds to their expected highest values.
  5. Changing the method of interpolation connected to 'Interpolate 2D Scattered VI'.
    • This does exactly what it suggests. I've stuck with 'biharmonic spline'.

 

This is the output of the biharmonic spline using the Zeros & Random Values text file.

Linty_C_0-1667574549981.png

 

What I'm aiming for is a 3D model of this.

Linty_C_1-1667574815258.png

0 Kudos
Message 3 of 13
(1,782 Views)

A snippet with glaring race conditions* and the absence of any data file make any help difficult. Then you show us a 2D picture explaining that you want a 3D model of "this". Way too ambiguous! I have no idea how that would look like!

 

Instead of a snippet, just zip your VI and your data file and attach it. Then explain exactly what you want to see!

 

* You are reading local variables (maxRx, etc.) way before their terminal receives any reasonable data. You need to eliminate all locals and only generate the ramps once the values are known, right? Dataflow! Execution order!

0 Kudos
Message 4 of 13
(1,768 Views)

Besides the race condition, the next place to look would be the index arrays. Are you sure you are getting what  you think you are?

 

Frozen_0-1667581003307.png

 

I find that LV always gets it wrong and I must transpose the 2D array to get the data that I want.

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 Kudos
Message 5 of 13
(1,749 Views)

@Frozen wrote:

Besides the race condition, ....


 

Yes, I only mentioned the tip of the iceberg. So many other things are wrong!

 

  • A format of %s is NOT the correct format to scan a DBL (fortunately, LabVIEW glosses over it and ignores the bad format).
  • Index array is resizable (60% less code!).
  • Once we see the data file, we can be sure that it is sufficient to read it as 2D array of DB directly. (90% less code!)
  • Are rx and ry linear and represent a rectangular grid?
  • ...

 

0 Kudos
Message 6 of 13
(1,744 Views)

My apologies - I thought I had attached the text files and the VI in the first message. As far as the VI goes, I didn't write it. I'm simply trying to fashion it to my needs.

 

Thank you.

0 Kudos
Message 7 of 13
(1,731 Views)

The data just seems to be a flat 2D array of z values, nothing more. I can't see where you want to get the x and y max values from.

0 Kudos
Message 8 of 13
(1,724 Views)

I have the nagging feeling that this is all you need:

 

(If you can guarantee that there are no NaNs, you can even eliminate the loop stack)

 

altenbach_0-1667591600786.png

 

0 Kudos
Message 9 of 13
(1,721 Views)

Sorry, I get an error when tryin to save for previous (due to the 3D graph). Here's the code with the graph parts missing: Just reassemble.

 

altenbach_0-1667592115120.png

 

 

 

 

0 Kudos
Message 10 of 13
(1,720 Views)