LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Eliminate empty string elements in an array

Message Edited by muks on 08-28-2008 02:36 AM
0 Kudos
Message 1 of 19
(5,534 Views)

Can you suggest a better way?

 

Message Edited by muks on 08-28-2008 02:43 AM
0 Kudos
Message 2 of 19
(5,527 Views)

Start building an array using only the strings that aren't empty. Works fine for relatively small arrays.

 

 clear string array

Message Edited by Bart Boshuizen on 08-28-2008 02:59 AM
Bart Boshuizen,
www.morechemistry.com
Message 3 of 19
(5,515 Views)

Hi muks,

we already discussed a solution here. Smiley Wink

Mike

Message 4 of 19
(5,504 Views)

Hi there

 

it's not clear what happens in the hidden cases. Please post complete shots or the vi itself.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Message 5 of 19
(5,502 Views)

If it's every 2nd element, you can use decimate array.

Also you could use the concat string funtion to create a single string. When your elements are all of the same width or empty, you can then slice the string into your string array.

 

Felix 

Message 6 of 19
(5,485 Views)

Instead of creating an array with every other element empty we can as well create the correct array directly.

See image.

 

Hope this helps,

Daniel

 

Message Edited by dan_u on 08-28-2008 10:30 AM
Message 7 of 19
(5,476 Views)
This is my vi and i would def like to eliminate the loop which is taking hellalot of time.My goal is complete this in 3 seconds.But it takes more than 15MIN!!!!!! using this.
0 Kudos
Message 8 of 19
(5,430 Views)

You are doing this extremely complicated, inefficiently, and incorrectly. First you place your U8 data in a DBL array,

increasing the memory usage by a factor of 8. Then you duplicate the array, only to generate the need to zero the

duplicates in the output array and the remove them later. Doing a 8bit to 16bit conversion is basically an atomic

operation in LabVIEW. The most inefficient way would be to convert the parts to a binary formatted string, concatenate

the strings, and the scan them back to a number. If you want to do this, you need to use format %08x for the formatting,

else things break.

 

I have no idea why you are scanning the result back into a I32, since it is only a 16bit number. U16 would be correct.

It seems you need to seriously learn about data representations.

 

Anyway, all you need is a typecast to replace everything except the first while loop.

Seems you want little endian, so you also need to swap the bytes.

 

There are many ways to do this, a simple way is shown in the image. In the while loop, initialize the array as U8.

 

Message Edited by altenbach on 08-30-2008 01:19 AM
Message 9 of 19
(5,426 Views)

It might be more efficient to convert the byte array to a string and then unflatten it as little endian U16 array.

 

Here's a quick rewrite of part of your code (remember, you need to built a U8 array from the visa data).

 

Message Edited by altenbach on 08-30-2008 01:48 AM
Message 10 of 19
(5,422 Views)