02-13-2024 02:25 AM
I have an array of four elements as a numeric value. Lets take element 1 is 90 and element 2 is 50 and element 3 is 70 and element 4 is 60 i need an output as reverse of first two elements result should be 5090 and another one is 6070.if anyone have some suggestions let me know it will be helpful.
02-13-2024 03:10 AM - edited 02-13-2024 03:29 AM
You mean something like below?
edit: the solution posted below by rolfk is the better solution.
02-13-2024 03:13 AM
Your data stream is in the so called Little Endian format (LSB first).
LabVIEW has an Unflatten from String function that can do that perfectly for you. You just have to convert your Byte Array first into a String (in LabVIEW a String is simply syntactic sugar for a Byte Array).
02-13-2024 03:35 AM
This one i tried already. Is there any other simplest way to achieve this.
02-13-2024 03:39 AM - edited 02-13-2024 03:46 AM
@Rajsakthi wrote:
This one i tried already. Is there any other simplest way to achieve this.
Define "simple". 😁
Same as above but with an extra alternative.
The first definitely scales much better if your data suddenly gets longer. The second is a bit more explicit if you know ahead that your input stream never will get larger.
02-13-2024 03:41 AM
Haha..Can we simplify the steps in a better way.
02-13-2024 03:43 AM
In this how can i add the 1d array to it....iam trying but not getting.
02-13-2024 03:47 AM
Hi Raj,
@Rajsakthi wrote:
In this how can i add the 1d array to it....iam trying but not getting.
In Rolf's example there already is an array input called "data in".
Why do you want to "add" an array? What is the math operation good for?
Why don't you show your current VI to allow us to give suggestions how to improve it?
02-13-2024 04:00 AM - edited 02-13-2024 04:06 AM
@rolfk wrote:
(...) The second is a bit more explicit if you know ahead that your input stream never will get larger.
The alternative is no good as it concatenates bit-wise, so 010011 (i.e. 50, LSB) concatenated with 0101101 (i.e. 90, LSB) to give 01011010010011 (12890, LSB).
02-13-2024 04:05 AM
@Rajsakthi wrote:
In this how can i add the 1d array to it....iam trying but not getting.
Not sure what you mean. All examples feature a 1D array, either as a control (rolfk's proposed solution) or as a constant (my reply).
Do you want a solution for a 1D array of general size (i.e. not limited to four elements)?