LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert 1D array of cluster of 2 elements to 2D array of double

Solved!
Go to solution

Hi everyone,

 

I tried to follow advice in other posts about this question, but that did not work. People suggested using a "cluster to array" inside a for loop, however I get a message that such a conversion is not accepted.

 

Have a look at the attached screenshot to see how things currently look like. The idea is to extract data from an XY graph automatically, not by right-clicking, and saving as a spreadsheet file.

 

Thank you very much in advance for helping.

0 Kudos
Message 1 of 14
(10,533 Views)

Is this what you  want to do?

0 Kudos
Message 2 of 14
(10,517 Views)

Thanks very much for replying. That's exactly what I was trying to do, but had an error as shown (see attached). The idea was to take all the data I have in my xy graphs and save it as lvm file. Would you know why I have a problem? It says that "Polymorphic terminal cannot accept this data type".

 

I've managed to solve this problem by using the data before it goes to the graph, but still would be interested in knowing why my for loop is not possible.

 

 

 

 

0 Kudos
Message 3 of 14
(10,501 Views)

Give me a screen shot of your control. It looks like you are trying to convert a signal array to a 2 dim array. The cluster to array function only works with clusters of the same data type. A waveform contains T0 (initial Time),dt (Delta Time in seconds) and y array (the samples.) Unbundle inside the for loop instead of convert cluster to array. and you will get the 2 dim array of doubles.  You can save waveform data directly to a tdms file. 

Message 4 of 14
(10,489 Views)

Please attach a (simplified version) of your VI and we will solve the problem quickly.

 

We cannot debug pictures.

Message 5 of 14
(10,450 Views)

Hi both,

 

attached is my Vi. The bit relevant to the question is where the error is. Now I am simply curious why that for loop cannot work the way it is. Thank you very much.

0 Kudos
Message 6 of 14
(10,442 Views)
Solution
Accepted by topic author PiotrW

Your cluster elements are 1-D arrays.  You can't turn 1-D arrays into a 2-D array using that function.

 

What you can do is Unbundle the cluster, then Build an Array of the 1-D array into 2-D arrays.

 

However you have this in a For Loop withe autoindexing would then turn the 2-D array into a 3-D array which doesn't sound right.  Do you want all these 1-D arrays to be concatenated to each other?  There are ways to do that and depending on your version of LabVIEW determines the best way.

 

 

Message 7 of 14
(10,431 Views)

Thanks very much for helping, I didn't previously realise that debundling was the solution... this should work. I'm still learning the basics (although managed to build that VI from scratch myself).

0 Kudos
Message 8 of 14
(10,426 Views)

There are some missing subVIs, so we cannot debug. Still...

 

Each element of the array is a cluster of two arrays. You cannot make an array of arrays. What kind of output do you actually want? What should be the datatype? We cannot proceed until you answer this.

 

Your "Local variable read...insert into array...concatenate array" is just plain silly. A concatenate array of height 1 is a plain NOOP. Use a feedback node and get rid of the local variable. Use "built array" Instead of "insert into array". In the loop, instead of built array followed by a concatenating tunnel, just use an indexing tunnel, right?

 

There is just way too much garbage code. Have you tried using complex arrays for xy data instead?

 

 

0 Kudos
Message 9 of 14
(10,415 Views)

The purpose of the main VI is to generate a series of graphs from a file, then you run the VI again and new curves are added to the graphs from other files, so that you can compare them. I realise the code is not optimised, but the local variable seemed necessary to do so. I have tried using the feedback node, but then what happened is that graphs only started appearing the second time you ran the main VI.

0 Kudos
Message 10 of 14
(10,406 Views)