LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question-Creatin array from a large # of scalars

Hello

I am developing LV code, where a large number of calculations are being done
in various ways as scalars. I would like to assemble these (say about 200
such) into a 1D array. I want to avoid using Build Array with 200 element
inputs. Also, these are not being generated within a For-Next loop to be
able to use the auto-indexing function or shift-registers.
Is there a relatively simpler way to create a 1D array from a large number
of scalars?
Reason I want to do this, is to make it easy to pass this array to other
vi's via a connector output or store to like a spreadsheet or send to a
printer.

TIA
Khan Kabir
Xerox Corp.
0 Kudos
Message 1 of 6
(3,027 Views)
Sounds like a job for Clusters. Put all your scalars into a cluster frame and then use the cluster-to-array vi to make a 1D array.
See my attached as an example.
Good Luck, Doug
0 Kudos
Message 2 of 6
(3,027 Views)
A possible solution can be to create an array initializing it with a non-expected value. In your case seems like it can be a negative number (assuming all your numbers are positive. If not, you can come up with another condition, like a number that is not likely to occurr). For example, you can create a 200 elements 1-D array using the "Initialize Array" vi, with all elements initialized to -1. Then, you can use the "Replace Array Element" to change the value of each element in the array as they are generated by your application. Keep track of the last element to be changed in the array by using the vi "Array Max & Min", checking the result of the "min index" output (Alternatively, you can use "Search 1D Array").

Just to mention, all this can be a lot more easy with L
abVIEW 6, as it include more and more appropriate functions to handle arrays for these type of situations. If it turns out that you have LV 6, I hope the option that I just propose for your situation can help you in achieving a more appropriate one.

Best regards;
Enrique
www.vartortech.com
0 Kudos
Message 3 of 6
(3,027 Views)
Hi Khan,

you can use Vi-Server to automatically build an array of values contained in controls or indicators of your front panel.
I attach a vi in LV6 that:
- Creates an array of references of all the front panel controls and indicators
- Extracts the values of a determined number of controls/indicators
- Converts each value in a DBL format (of course it can be changed)
- Builds an array of values extracted

N.B. the order of the references array refers to the order of the controls/indicators on your panel. It's important that you set correctly the panel order to make this vi build an array of the wanted controls/indicators; to access panel order: Edit - Set Tabbing Order. If for instance you want to make an array of 5 controls but in your panel you have a boolean at
order #3 you will get an error ( you can't convert a boolean to DBL...)

Let me know if you need more help.

good luck,
Alberto
0 Kudos
Message 4 of 6
(3,027 Views)
You'l have to connect the 200 scalars to SOMETHING to bundle them
together. To avoid having to have all 200 in one place, you can insert
them into the array at different locations in your diagram using
Insert Into Array.
Zuolan
"Khan Kabir" wrote in message news:<9glp5h$hap$1@news.wrc.xerox.com>...
> Hello
>
> I am developing LV code, where a large number of calculations are being done
> in various ways as scalars. I would like to assemble these (say about 200
> such) into a 1D array. I want to avoid using Build Array with 200 element
> inputs. Also, these are not being generated within a For-Next loop to be
> able to use the auto-indexing function or shift-registers.
> Is there a relatively simpler way to create a 1D array from a large number
> of s
calars?
> Reason I want to do this, is to make it easy to pass this array to other
> vi's via a connector output or store to like a spreadsheet or send to a
> printer.
>
> TIA
> Khan Kabir
> Xerox Corp.
0 Kudos
Message 5 of 6
(3,027 Views)
Another thought after my first email. You may want to Bundle them into
cluster instead of making an array. This will make it easier when you
need to retrieve the scalars. Also you can bundle them into (say) 10
clusters then bundle these into a (higher level of) cluster. This will
make it more managable especially when you bundle the first level in a
meaningful way.
Zuolan Wang
"Khan Kabir" wrote in message news:<9glp5h$hap$1@news.wrc.xerox.com>...
> Hello
>
> I am developing LV code, where a large number of calculations are being done
> in various ways as scalars. I would like to assemble these (say about 200
> such) into a 1D array. I want to avoid using Build Array with 200 element
> inputs. Also, these are not being generated within a For-Next loo
p to be
> able to use the auto-indexing function or shift-registers.
> Is there a relatively simpler way to create a 1D array from a large number
> of scalars?
> Reason I want to do this, is to make it easy to pass this array to other
> vi's via a connector output or store to like a spreadsheet or send to a
> printer.
>
> TIA
> Khan Kabir
> Xerox Corp.
0 Kudos
Message 6 of 6
(3,026 Views)