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: 

Array issues

Solved!
Go to solution

Hi, having a bit of trouble setting up an array .

The readings came out as a string which I converted into an array which appears as:

1.0001 101 1.0002 102 1.0001 103 1.0001 104

Instead i would like it to be 

1 101 1.0001

2 102 1.0002

3 103 1.0001

4 104 ...

 

Once I get more scans id like it to be:

              1           2 

1 101 1.0001  1.0001

2 102 1.0002  1.0003

3 103 1.0001  1.0003

4 104 ...

 

Any help appreciated 

0 Kudos
Message 1 of 11
(2,727 Views)

You must have some sort of other delimiter to tell it to start the array on a new line. I don't have the instrument driver you have, so I can't actually run your code, but you're close. For Spreadsheet String to Array, it's expecting a newline or carriage return character to say "start a new line in the output array".

 

Right click your "Readings" control and select "\ codes display", then run your code, and see if there are any characters between the 1.0001 and 102 (in your example below). If there are none, you'll have to change something with your instrument driver, as otherwise the spreadsheet string can't figure out where to put the new elements.

 

If there are no newline characters, you could use "Reshape array" and reshape the 1D array to 2D.

0 Kudos
Message 2 of 11
(2,711 Views)

You should be a bit more careful when coding, for example %F is not a valid format (fortunately, LabVIEW will ignore it and work anyway) and a scalar DBL is NOT an array type.

 

Wire a 1D DBL array as type. once you get a 1D array out, you can reshape it to a 2D array with two columns, get the columns using "index array" and reassemble as desired. Personally, I would build the transposed array, because appending rows later is much cheaper than appending columns. You can always transpose it for display. Let us know if you need help with that.

 

Can you show is the toplevel VI? This one does not have a toplevel WHILE loop (I assume you are not using the continuous run: button). Once you have a toplevel loop build the array in a shift register and append the new data.. Is the data for the first column always the same and always in the right order?

 

 

 

 

0 Kudos
Message 3 of 11
(2,708 Views)

How do I wire a 1d dbl as an array type?

0 Kudos
Message 4 of 11
(2,655 Views)

@newman3108 wrote:

How do I wire a 1d dbl as an array type?


In newer versions, you just put down a Double constant, right-click on it, and choose to change it to an array.  In older version, you will need to drop an array constant and then drag a Double constant into it.


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 5 of 11
(2,647 Views)

Thanks for all the help

So ive done it slightly a different way, ive separated the channel list and measurements then built an array:

101 25.3

102 25.1

103 25.2

 

How do I then add the next set of measurements into the next column when running continuously?

0 Kudos
Message 6 of 11
(2,642 Views)

@newman3108 wrote:

How do I then add the next set of measurements into the next column when running continuously?


It is a lot simpler if you had your columns be the channels and each row a new measurement.  Then it is a simple Build Array to add measurements.


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
0 Kudos
Message 7 of 11
(2,614 Views)

i realised that and switched them around, there could 1000's of scans though so how do I add it to a new row automatically. Ive tried using insert into array but that doesnt work

0 Kudos
Message 8 of 11
(2,612 Views)

@newman3108 wrote:

i realised that and switched them around, there could 1000's of scans though so how do I add it to a new row automatically. Ive tried using insert into array but that doesnt work


1. You should be storing your array in a Shift Register.

2. You should be using Build Array, not Insert Into Array.

3. Adding 1000s of scans will eat up A LOT of memory.  Maybe you should just use a Chart and it will only display the last X number of samples (defaults to 1024 samples).


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
0 Kudos
Message 9 of 11
(2,589 Views)

okay thank you 

Ill need every data point in the end to analyse in excel. 

My plan was: shift register> array>graph> excel.

Is there a better way of doing this?

0 Kudos
Message 10 of 11
(2,572 Views)