LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to resize a troublesome array

Solved!
Go to solution

The VI below outputs data in a column but I need it in a row. How do I do that? I have tried using the Resize Array vis but I have been unsucessful. 

A couple of clues might be that the first row of the column is two elements and the vi is putting a coma at the end of the last item.

I would really like to make the milisecond timer reflect the time after each set of readings of the registers from the start but have not been able to find out how to do that either. 

 

Column

22808,48658
-40.147385,
3.459666,
0.032125,
04:58:16.492 02/01/1904,

 

Row
22808,48658,-40.147385,3.459666,0.032125,04:58:16.492 02/01/1904

0 Kudos
Message 1 of 24
(715 Views)

Please do a "save fore previous" (2020 or below) and attach again so more can actually look at your VI. Make sure all controls have reasonable default value.

 

There is no difference between a 1D array that is vertical or horizontal. Arrays are a collection of elements distinguished by their index and value.

 

You seem to have a single string that differs in delimiters. Not clear at all from the description.

0 Kudos
Message 2 of 24
(685 Views)

OK, I am on a VM where I can read your VI.

 

There is a lot of code smell.

 

  • Why are you are appending (to file) the exact same data 10 times in a loop? Seems redundant. How should the final file look like (rows? Columns? Which column is time?, etc)
  • Your outer while loop is a fake FOR loop, because the number of iterations is known before the loop starts, so use a FOR loop instead.
  • I can't tell where your rows/columns are that you mentioned. Can you reduce it to a simple VI that has just the relevant arrays? (how big is the blue array? What's the value of the "change to 2 registers" control? Easiest would be just a loop stack that simulates data because we don't have your instruments.
  • If you want a timestamp with each read, you need to do that in the inner loop. Currently, you only get the time from the last iteration of the inner loop.
  • Maybe some of your outer tunnels should not be "last value".
0 Kudos
Message 3 of 24
(657 Views)

@EdHarris wrote:

The VI below outputs data in a column but I need it in a row. How do I do that? I have tried using the Resize Array vis but I have been unsucessful. 

 


Transpose the 2D array or use the Transpose input on Write to Spreadsheet file. As Altenbach wrote, writing the same data 10 times is just silly.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 4 of 24
(620 Views)

Hi Ed,

 


@EdHarris wrote:

The VI below outputs data in a column but I need it in a row. How do I do that?


Why don't you use the Transpose1DArray function?

The function icon clearly shows how to transpose from column to row… 🙂

 

Spoiler
In case someone doesn't catch the fun smiley: this post isn't intended as meaningful suggestion!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 24
(614 Views)

@GerdW wrote:

Why don't you use the Transpose1DArray function?


Thankfully, it operates in-place. 😄

altenbach_0-1764182555668.png

Also, why doesn't this work? 😮

 

altenbach_0-1764182935504.png

JK...

 

0 Kudos
Message 6 of 24
(548 Views)

See if this can give you some ideas....

 

 

(I really don't know where you want the timestamp and how the data should be arranged I also don't understand why you would format a relative time as absolute time.)

Message 7 of 24
(527 Views)

About Altenbach' earlier questions, I set up two slaves acting as four so that I could test that the reading order was correct. The 10 readings will be something like 3000 if I can get it working.

 

I tried useing the resize array vi before the write to spreadsheet file vi. The first dimension size specifyer is rows and the second columns right? I have six elements in a column (like below) so to change that to a row should be 6 and 1. But that changes this:

 

55004,48655                        two registers
-40.149040,                          third register
3.212547,                             fourth register
0.034597,                             last register
23:59:58.844 31/12/1903,    milisecond timer

 

to this


39592,48655,-40.156555,,3.459666,  first two registers, third register, gap, fourth register, missing.

 

I have tried putting the resize array vi at every point along the data pipeline including in the cases but each altenative reduces the amount of data printed.

now looking at other comments thanks

0 Kudos
Message 8 of 24
(517 Views)

I didnt know Transpose 1D array existed because it is not available in my version but then I couldnt make it work, but trying again with the transpose 2D aray is a slight improvement giving output like this;

 

FIrst of two elements, third element, fourth element, fith element, milisecond timer

Second of first two elements, padding.

 

52900,-40.134930,3.459666,0.032125,23:59:58.855 31/12/1903
48655,,,,

 

I think the problem is that the output of the case structure in the true case is  two elements in a row and the false case it is 3 elements or one element four times? (not sure if  in a column), that data above with the second of the first two elements on the second row could be evidence, driving  me crazy

0 Kudos
Message 9 of 24
(497 Views)

@EdHarris wrote:

I didnt know Transpose 1D array existed because it is not available in my version but ...


Transpose 1D atray is a silly joke. No purpose and not useful.

0 Kudos
Message 10 of 24
(473 Views)