From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Text file to 3D graph

Hi all LabVIEWers!

 

I have some troubles with text files and 3Dgraph. I´ll try to explain myself: 

 

I´ve got a text file .txt with different data. The first 14 rows are just for information, so I do not need them right now. 

 

My first question is how to extract data from text file in order to be able to work with the array of numbers (see texttoarray.vi attached). If I´m able to do this, the second question arrives: how to plot the data? In the example below, the data from the current column becomes my Z data as a function of the second and the third column. 

 

Current              X             Y

 -2,25E-11        12,5         2
 -2,23E-11        13,0         2
 -2,10E-11        13,5         2
 -2,26E-11        14,0         2
 -2,13E-11        14,5         2
 -2,29E-11        15,0         2
 -1,94E-11        12,5         2,5
 -2,03E-11        13,0         2,5
-2,17E-11         13,5         2,5
 -2,12E-11        14,0         2,5
 -2,27E-11        14,5         2,5
 -2,42E-11        15,0         2,5

 

However, the current data should stay in an expanded matrix as a function of X and Y, such as this: 

 

 Y/X     12.5                      13                        13.5                    14                           14.5                       15

2         -2,23E-11            -2,10E-11           -2,10E-11          -2,26E-11             -2,13E-11             -2,29E-11

2.5     -1,94E-11            -2,03E-11           -2,17E-11           -2,12E-11             -2,27E-11            -2,42E-11

 

This way, I would have an X and Y vector and a 2D array for Z, the inputs I need for the plot. But, can someone help me with this problem? I´ve been trying to do something but I failed in all my attempts. 

 

Thank you all!

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

Hi lacorgui,

 

for easy transformatoin you need to know the number of unique X and Y entries. You can get that information either from your 14 header rows or by scanning the data.

 

Onve you know that you can create a 2D array of needed size and store your Z values in that array. To find the Z array indices you just look up your X and Y vector…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(3,007 Views)

I´ve been able to get the matrixs I need for the 3D graphs (see attached .vi and .txt file: xpoints is 10 and ypoints is 7 for this particular text file). However, my problem now is that I do not get any image in the graph, do someone knows what I´m doing wrong?

 

Thanks again

 

Download All
0 Kudos
Message 3 of 7
(2,982 Views)

Hi,

Are you sure that the Format you introduce in Read From Spreadsheet File.vi is correct?

If you look at context Help in LV for the format the information you obtain is :

 

format specifies how to convert the numbers to characters. If the format is %.3f (default), the VI creates a string long enough to contain the number, with three digits to the right of the decimal point. If format is %d, the VI converts the data to integer form using as many characters as necessary to contain the entire number. If format is %s, the VI copies the input string. Use the format string syntax.

 

In you case, the format is set to %^.3e.

best regards,

 

 

Kudos are welcome :smileywink:

Message 4 of 7
(2,946 Views)

Finally I got what I wanted (more or less). Now, I am able to create a graph (intensity) from my text file, just running the small program attached (text2graph). However, I´m still fighting in order to get the surface or contour graph. 

 

Thanks for all your support!

0 Kudos
Message 5 of 7
(2,936 Views)

Hi,

 

I believe there is a 3D Countour graph built into LabVIEW. When you place it on the front panel, it automatically puts a helper VI on the block diagram that takes the inputs you have in your text file. (A X and Y vector and a Z 2D array.)

 

This link talks about the 3D functions in LabVIEW.

 

http://zone.ni.com/reference/en-XX/help/371361L-01/lvhowto/plotting_3d_graphs/

 

If you use the search tool in LabVIEW (right click on the front panel and click the magnifying glass on the resulting pop-up menu) and type countour, you will go directly to the palette where these graphs are located.

 

 

0 Kudos
Message 6 of 7
(2,920 Views)

Hi clendon.gibson, 

 

I tried that but it seems not to work in my case (even with my x and y vector and my 2d matrix Z). If I try, there is no problem with the program, but the graph is empty somehow. I´ll keet trying and post if I got it! 

 

Thanks

 

 

 

 

0 Kudos
Message 7 of 7
(2,915 Views)