04-18-2014 05:10 AM - edited 04-18-2014 05:10 AM
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
Solved! Go to Solution.
04-18-2014 06:42 AM
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.
04-18-2014 07:33 AM - edited 04-18-2014 07:35 AM
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
04-18-2014 08:04 AM - edited 04-18-2014 08:04 AM
Something like this?
04-18-2014 08:29 AM
That's the result I want, but I can't do it that way. Here is why
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.
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
04-18-2014 08:46 AM
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.
04-18-2014 09:08 AM
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.
04-18-2014 09:14 AM
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.