LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to resize a troublesome array


@EdHarris wrote:


23:59:58.844 31/12/1903,    milisecond timer


As I already said, formatting a millisecond time in absolute time of the LabVIEW epoch, giving century old data in early 1903 makes no sense at all.

0 Kudos
Message 11 of 20
(124 Views)

@EdHarris wrote:

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


In the false case you are combining two I16 into a 32bit integer and casting it to a DBL to be formatted as string and you only get exactly one element.

In the true case, you are formatting N I16 integers and you still have not told us what N is.

 

Since the data you are showing has decimal delimiters, this makes no sense. It is still not clear at all how much data each inner loop produces and where you want to add the timestamp. 

 

if you want to concatenate the various 1D arrays of the inner loop, just use a concatenating tunnel and prepend (shown) or append (not shown) the ms timer value of the outer loop. If you repeat it 10 times in the outer loop, you get 10 rows, differing in the timer value (but I assume that in your case the instrument reading might change, why else would we need the outer loop?). See if this simulation ca give you some ideas.

 

altenbach_0-1764257817042.png

 

Message 12 of 20
(115 Views)

I see 1D 😆.

I really think the problem is with the output of the true case and false case not matching. The true case is two elements passing out as a one row two column array and the false case is one element. I have tried correcting it inside the case structure with various combinations of resize array or transpose 2D array but cannot make it work. What am I missing? Or can I do something different with the number to fractional string VI?

I have posted my failed modifications below

0 Kudos
Message 13 of 20
(97 Views)

You should only have a built array in the FALSE case (creating a 1D array with 1 element) and nothing in the TRUE case (leaving the 1D array as is), then use a concatenating tunnel at the next loop boundary as I showed earlier.

 

(Your outer loop is still completely pointless because it only outputs the data from the last iteration.)

0 Kudos
Message 14 of 20
(83 Views)

OK thanks, whats that arrow vi in the inner loop in your example?

0 Kudos
Message 15 of 20
(81 Views)

Yes. Right-click the tunnel and select "concatenating". It will append all the 1D arrays (even of different lengths) from all iterations automatically.

 

(Back in the old days, we would have used a shift register and use built array in append mode instead)

0 Kudos
Message 16 of 20
(81 Views)

@altenbach wrote:

@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.


Actually, "Transpose 1D Array" is not a "joke", it is the answer to the question "Why is a 1D Array different from all other Arrays (in LabVIEW)?".

 

The answer is that if you consider a 1D Array as a "Row" Array (because the Control and Indicator by convention are written with successive elements arranged in a horizontal row, and only needs one Index.  By convention, (established >30 years ago) a "Column" Array is a 2D Array with N Rows and a single Column.

 

Here, for your amusement, is "Transpose 1D Array" (I'm using a 5-element I32 Array in this particular example):

Transpose 1D Array.png

 

[I need to admit that when Gerd posted this "non-existent function", I said "Hmm, I don't remember that, must have been added in 2025", but Altenbach's reply clued me in that the Joke was on Me, so it's only fair to make this a "Teaching Moment"].

 

Bob Schor

0 Kudos
Message 17 of 20
(53 Views)

 

 

 

 

Well I was fooled because they called it an array which must have at least 2 elements and therefore an axis.

0 Kudos
Message 18 of 20
(40 Views)

Do you have a MATLAB background? In MATLAB, everything is at least a 2D-array. That makes differentiating between row and column vectors at all meaningful. LabVIEW has no such concept and if pressed will default to row-major ordering. That is difficult for people coming from MATLAB, which is column-major. (I might be self-injecting here).

 

NI_Matrix:Array to Matrix for 1D-arrays looks exactly like Bob wrote

array to column vectorarray to column vector

 

An array can have also have zero elements. 

0 Kudos
Message 19 of 20
(33 Views)

@Bob_Schor wrote:
Here, for your amusement, is "Transpose 1D Array" (I'm using a 5-element I32 Array in this particular example):

 

I do plenty of linear algebra to be familiar row and column vectors. Transpose 1D array  does not output a 2D array with one column and I have absolutely no idea what it actually does. It does seem to somehow tag the output as "columnvector" so there must be a purpose for its existence. Would be interesting to learn more.

 

altenbach_0-1764419622687.png

 

What has also confused people in the past is the fact that you can have an empty 2D array where either the row or column size is nonzero. (... similar for higher dimensions. An array is empty of the product of all dimension sizes is zero, i.e. if at least one dimension is zero size).

 

 

 

0 Kudos
Message 20 of 20
(23 Views)