LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

1st Element Subarray of 2D array, still 2D array?

Solved!
Go to solution

Hello all,

 

I'm working on receiving bytes in from VISA serial. I'm starting to try to manipulate them, starting with grabbing off the first byte...wanting to turn it to a U8 number I"m thinking to evaluate it.

 

I'm trying to use a subarray to pick off the first row 8 bits long. I would think picking off one row off a 2D array would result in a 1D array, in this case...one that is 8bits long.

 

But when I try to hook a boolean array to number, it complains that it is being hooked to a 2D array...I'm not sure I understand where the 2nd dimension is coming from?

 

subarray_to_number_error.png

 

Suggestions?

 

Thank you,

 

cayenne

0 Kudos
Message 1 of 5
(2,687 Views)
Solution
Accepted by topic author cayenne

It has to be a 2-D array.  Suppose you were picking off 2 rows, it has to be a 2-D array.  You can't change the datatype on a wire during run-time.  It has to be determined at compile time.

 

If you only want the first row, then the correct function to use would be Index Array.  Index off the first row.

Message 2 of 5
(2,686 Views)

@Ravens Fan wrote:

It has to be a 2-D array.  Suppose you were picking off 2 rows, it has to be a 2-D array.  You can't change the datatype on a wire during run-time.  It has to be determined at compile time.

 

If you only want the first row, then the correct function to use would be Index Array.  Index off the first row.


Thank you for the reply.....at first I was having some problems with the Index Array...started trying to delve deeper into the help screens...I think I have it.

 

If I want the first row, I just put that index in (0).....and leave the colum part unwired...that will give me the entire first row...right?

 

subarray_to_number_error_2.png

 

Does this look to be about what you were describing?

 

Thank you....almost there...

 

C

0 Kudos
Message 3 of 5
(2,684 Views)

Yes.  That would be it.  But I'd argue to do it on the blue wire before the For Loop.  There is no reason to do the conversions on the entire array in the For Loop when you are only using the first number.  And since you are just converting it back to a number anyway, why bother converting it to a boolean array?

Message 4 of 5
(2,682 Views)

@Ravens Fan wrote:

Yes.  That would be it.  But I'd argue to do it on the blue wire before the For Loop.  There is no reason to do the conversions on the entire array in the For Loop when you are only using the first number.  And since you are just converting it back to a number anyway, why bother converting it to a boolean array?


Thank you.

This is just a sample of the actual vi...I'm also going to be converting the whole thing to strings to display on a large test indicator element on the gui...hence that loop part....

 

But good suggestion, I was doing the display first....and now moving to parsing out the data...so, some re-design is called for.

 

Thank you again for the excellect help and suggestions!!

 

cayenne

0 Kudos
Message 5 of 5
(2,679 Views)