LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
falkpl

Create new empty array

Status: Declined

Any idea that has received less than 4 kudos within 4 years after posting will be automatically declined.

 

 

 Often I find that i need to create a empty copy of an existing type, this is essentially done by indexing the array and then creating an empty array of the indexed type.  Essientally many array manipulation is done this way.  It would be nice if there was a single function that does this.

 

 

 

This code:

 Create New array by type.JPG

 

Is replaced by this code:

Create New array by type new.jpg

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
5 Comments
Marc Blumentritt
Member
What about using Subarray with length=0?
CLD
falkpl
Trusted Enthusiast
Never thought of that, been using 2 functions instead on one all these years. 
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
altenbach
Knight of NI

 > What about using Subarray with length=0?

 

Better than "subarray" is "reshape array". Fewer inputs. 🙂

 

 

"Reshape array" is also safer. For example if you keep the length of array subset unwired, assuming it will default to zero, you'll get the entire array instead by accident.

Reshape requires a size input, forcing you to be explicit.

 

.

Message Edited by altenbach on 06-26-2009 10:52 AM
JackDunaway
Trusted Enthusiast

I like your initial idea, except I would like to expand it. Sometimes you want to create an array of length N with the default value of the wired datatype, so the combination of the index/initialize is more appropriate. Fundamentally, I'm asking for the Initialize Array command to accept an array as the input datatype, and use the default value of an element as the fill value.

 

Especially in the example you gave... it looks like if you are shifting around an initially empty array, you will be adding elements to it. In many cases you will gain performance by initializing an array with N elements, then trimming it (rather than appending to the array conditionally every iteration).

Message Edited by mechelecengr on 06-29-2009 05:46 PM
Darren
Proven Zealot
Status changed to: Declined

Any idea that has received less than 4 kudos within 4 years after posting will be automatically declined.