LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can someone explain array initi

alization to me. I am attempting to initialize an array with a 2d array constant full of zeros, then insert data into that array as I measure it using the "insert into array" vi within a while loop. The result output is a 2d array of nothing. Any ideas?
0 Kudos
Message 1 of 10
(4,115 Views)
alization to me. I am attempting to initialize an array with a 2d array constant full of zeros, then insert data into that array as I measure it using the "insert into array" vi within a while loop. The result output is a 2d array of nothing. Any ideas?You're doing almost everything right except replace 'insert into array' with 'replace array element'. The index should be wired off the loop index (and something else for the other index).

jared
0 Kudos
Message 2 of 10
(4,116 Views)
alization to me. I am attempting to initialize an array with a 2d array constant full of zeros, then insert data into that array as I measure it using the "insert into array" vi within a while loop. The result output is a 2d array of nothing. Any ideas?Thanks for your suggestion. I have attached a vi that show what I am trying to accomplish. It works perfectly the first time and not at all after that. Any suggestions?
0 Kudos
Message 3 of 10
(4,115 Views)
alization to me. I am attempting to initialize an array with a 2d array constant full of zeros, then insert data into that array as I measure it using the "insert into array" vi within a while loop. The result output is a 2d array of nothing. Any ideas?Use build array!
If you don't need iteration number.
"Tomcat" wrote in message
news:5065000000050000003A1F0000-984882144000@quiq.com...
> Thanks for your suggestion. I have attached a vi that show what I am
> trying to accomplish. It works perfectly the first time and not at
> all after that. Any suggestions?



[Attachment stream_to_array.vi, see below]
0 Kudos
Message 5 of 10
(4,115 Views)
alization to me. I am attempting to initialize an array with a 2d array constant full of zeros, then insert data into that array as I measure it using the "insert into array" vi within a while loop. The result output is a 2d array of nothing. Any ideas?Using "Build Array" is very inefficient and gives a big performance hit.
That's why people do it this way when necessary.

The initialisation is screwed. You don't initialise the shift register with
an empty array, you initialise the shift register with an array that has
been initialised to the required dimension using the "initialise array"
node. As someone else has pointed out, you need to use "Replace Array
Element" and NOT "Insert into array". Using the latter as you have done has
the same drawbacks as using "Build Array" in that all the existing data has
to be copied to a new array each time you add new data. The "replace array
element" will only replace existing elements- if you try and replace an
element that doesn't exist then n
othing happens. So obviously in the
attached example where nothing initially exists, nothing will ever happen.

Also, when you do things this way, you need logic to wrap the counter back
to the start when the end of the array is reached to implement a circular
buffer- else your counter just keeps going up indefinitely and runs off the
end of the array. In Labview this does nothing. In other less forgiving
languages it will cause a crash. If you don't want a circular buffer, you
need to stop the loop when the iteration counter is equal to or exceeds the
number of elements with which the array has been initialised.

I've attached a modified version of the example.

njh wrote in message
news:3ac040a3@newsgroups.ni.com...
> Use build array!
> If you don't need iteration number.
> "Tomcat" wrote in message
> news:5065000000050000003A1F0000-984882144000@quiq.com...
> > Thanks for your suggestion. I have attached a vi that show what I am
> > trying to accom
plish. It works perfectly the first time and not at
> > all after that. Any suggestions?
>
>
>



[Attachment stream_to_array.vi, see below]
0 Kudos
Message 6 of 10
(4,115 Views)
alization to me. I am attempting to initialize an array with a 2d array constant full of zeros, then insert data into that array as I measure it using the "insert into array" vi within a while loop. The result output is a 2d array of nothing. Any ideas?Thanks! This helped. I was trying to force Labview to build my arrays but now I see this doesn't work.
0 Kudos
Message 7 of 10
(4,115 Views)
alization to me. I am attempting to initialize an array with a 2d array constant full of zeros, then insert data into that array as I measure it using the "insert into array" vi within a while loop. The result output is a 2d array of nothing. Any ideas?hi,
If you know the number of 2Ddata (array size) that you are gonna to acquire, initialising the array will help by eliminate the need to reallocate array memory.

Here's a modified version of your vi. note that "initialse array" is used to allocate an array memory.

Cheers
ian.f
sg/my
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 Kudos
Message 9 of 10
(4,115 Views)
alization to me. I am attempting to initialize an array with a 2d array constant full of zeros, then insert data into that array as I measure it using the "insert into array" vi within a while loop. The result output is a 2d array of nothing. Any ideas?Do you use version 6.0 series?
I cannot find out "insert into array" vi, but to make it easy
you may use "repalce array elements" vi at each steps in a
while loop.

Tomcat wrote:

> Can someone explain array initialization to me. I am attempting to
> initialize an array with a 2d array constant full of zeros, then
> insert data into that array as I measure it using the "insert into
> array" vi within a while loop. The result output is a 2d array of
> nothing. Any ideas?
0 Kudos
Message 4 of 10
(4,115 Views)
alization to me. I am attempting to initialize an array with a 2d array constant full of zeros, then insert data into that array as I measure it using the "insert into array" vi within a while loop. The result output is a 2d array of nothing. Any ideas?You can only replace elements if there are elements.
So, perhaps you have not correctly initialized your array.
For example: You have an 2D array called A. If you want to replace element
A[2,3] you must have to initialized your array with the dimesionsizes 2 and
3.

Max


--
-> max.weiss@web.de / max@gmx.de <-
-> Max Weis * Eulenweg 2 * 76356 Weingarten * Germany <-
-> Fax: 0180 505254775181 * Tel: 0175 1228001 * DB 8 MWE <-
0 Kudos
Message 8 of 10
(4,115 Views)
alization to me. I am attempting to initialize an array with a 2d array constant full of zeros, then insert data into that array as I measure it using the "insert into array" vi within a while loop. The result output is a 2d array of nothing. Any ideas?Please see the attached bmp file.
The simple routine gives you a 2x2 array (2D) with all zeros in it. You can change value input to the dimension size of the INIT ARRAY as you wish.

I hope this answers your question
0 Kudos
Message 10 of 10
(4,115 Views)