LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Making a .txt file from different 3 1D-array's

Solved!
Go to solution

Hi NI community

 

I have been searching a decent solution for this problem, but I can't figure out how to do it.

 

So I have a subVI that calculates 3D coordinates out of different images. Every image contains around 200 points that will be calculated. The output of the subVI are 3 1D-arrays, one for every dimension. I want to make a .txt file where the coordinates are written like this:

 

x1; y1; z1

x2; y2; z2

x3; y3; z3

...; ...; ...

xn; yn; zn

 

The coordinates from every picture that goes into the calculation VI should be added into this .txt file with respect to the described structure.

 

Is there anyone who got experience with this and know a proper solution? If something is not clear to you, please ask me to explain you.

 

 

Kind regards

Ruts

 

0 Kudos
Message 1 of 8
(2,985 Views)

Use Build Array to combine the three 1D arrays into a 2D array.  Now just use the Write To Spreadsheet File VI.  Based on your example, you will want to set ';' to be the delimiter.  You may also have to set the Transpose input to TRUE.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 8
(2,966 Views)

Thank you for your answer crossrulz.

 

For the write spreadsheet:

I wasn't familiar with that vi. I have tried it and it does answer my needs, thanks for that.

 

For the build array part:

The build array vi was the first thing I tried in the begin, but the problem is that the array is shaped like this for n images.

image 1: x1 x2 x3 x4 x5 .... xn y1 y2 y3 y4 y5 ... yn z1 z2 z3 z4 z5 ... zn

image 2 : x1 x2 x3 x4 x5 .... xn y1 y2 y3 y4 y5 ... yn z1 z2 z3 z4 z5 ... zn

....

Image n : x1 x2 x3 x4 x5 .... xn y1 y2 y3 y4 y5 ... yn z1 z2 z3 z4 z5 ... zn


I need an array where the x coordinates are in the first column, the y coordinates in the second column and the z coordinates in the thirth. I did manage to do this by using build matrix (append by column option), but this only works when I apply it to one image.

 

I need an array from 3 columns where the coordinates from the images add at the end of the coordinates from the previous image.

 

If this is solved I'm good I guess.

 

Kind regards

Ruts

0 Kudos
Message 3 of 8
(2,955 Views)

Something like this?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 8
(2,948 Views)

That's the result I want, but I can't do it that way. Here is why

 

LV1.JPG

 

Because of the indexing my results of the next 1D array show up on the right of the last 1D array as you can see in the next picture.

LV2.JPG

 

I can't use the build array.vi for my 1D arrays because I don't know how many  images (number of 1D arrays) will be processed. If I only could apply your solution to the indexing function my problem would be solved.

 

Do you have a solution for this?

 

Kind regards

Ruts

0 Kudos
Message 5 of 8
(2,937 Views)
Solution
Accepted by topic author RutsT

I don't know how your picture at the top compares with what you've shown up to this point.

 

You can combine multiple 1-D arrays without knowing how many there are.  You put the build Array in a For Loop.  Maintain the growing 2-D array in a shift register, and add each new 1-D array to it with the build array inside the For Loop.

Message 6 of 8
(2,929 Views)

What version of LabVIEW are you using?  Starting with 2012, there is a really cool tunnel option for you.  Right-click on your autoindexing tunnels and choose Tunnel Mode->Concatinating.  That will turn your outputs into 1D arrays.  Just use the Build Array from there.

 

The next option I would use is the Reshape Array function to change the 2D arrays into 1D and then use Build Array.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 8
(2,922 Views)

I use LV2011 on my desktop and LV2013 on my laptop. I did use the solution from ravensfan to my VI and it works. I'd like both of you for helping me out in such a short time.

0 Kudos
Message 8 of 8
(2,919 Views)