LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert 1D string array to 2D array

f.png

 

Hi , as can be sen in the picture. I have a 1D array of string and I would like to convert it into a 2D array in a way that

 

1. number of rows are the same

2. 2D array has 4 columns and based on a start point ( 2 in thsi example ( start from second column) it should put every 8 chars in one column). So since I have 16 chars it should seperate them into 2 rooms. Could you please help me to implement this in LabVIEW

 

thanks

0 Kudos
Message 1 of 16
(4,829 Views)

What part is giving you trouble?

 

The best way to get help is to show what you have tried and ask specific questions about the parts you do not understand.

 

Can you create a suitably sized 2D array?

 

Can you separate the input strings into the desired segments? What happens if the number of characters is not an integer multiple of 8?

 

Can you place the segments into the 2D array appropriately?

 

Lynn

0 Kudos
Message 2 of 16
(4,823 Views)

Need some more details.

 

What have you tried so far?

 

Did you intend for the start text on your VI to be a control to determine the start column?

 

Are you filling in an empty array or do you want to preserve the contents of an existing array if start=2 and the array already has data in column 1?

 

Split String, Build Array, and Replace Array Subset will be your friends here.

0 Kudos
Message 3 of 16
(4,822 Views)

Hi Lynn,

 

I can make a 2D array with the size I need 16x32 and I think I should use Scan From String to convert the string to U16 or U32, but I don't know how to chop that ( every 8 char) and then insert them in the appropriately location. It is always multiple of 8 , there is no problem with that part

0 Kudos
Message 4 of 16
(4,806 Views)

Hi taki

 

Yes start text specifies which column to start and depend on the number of chars( multiple of 😎 it should insert them in the next columns . I should do it for every row

0 Kudos
Message 5 of 16
(4,803 Views)

The conversion to number is a key element that you left out.

 

Scan From String to get U32s.

Then do a Split Number to get 4 U8s.

 

 EDIT:

Or do a Scan From String to get 4 U8s directly.

0 Kudos
Message 6 of 16
(4,801 Views)

Which start text?

You dont need to convert the string to U8's, just use the 'String subset' as it's all strings (unless you need to interpret the value for some reason). As for target array i'd precreate it and use Replace array element.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 16
(4,786 Views)

I have attached what I have done so far

 

using this VI I can insert the array in the appropriately position but I can't chop it and add it to the next column. ( Let's say I should chop in multiple of 4) so 0101 should go to teh next column. Can you help me to complete this

0 Kudos
Message 8 of 16
(4,751 Views)

Your VI doesn't do anything except allocate the array.

Try and implement one of the solutions that has already been suggested using String Subset or Scan From String or Split String.

0 Kudos
Message 9 of 16
(4,726 Views)

You don't have 16 bits there, so converting the string to a number won't work (probably give you an error). Try what has been suggested above.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 10 of 16
(4,722 Views)