取消
显示结果 
搜索替代 
您的意思是: 

Dynamically build an array

已解决!
转到解答

I want to dynamically build an array like in the image below. The problem I'm having is the previous element is being reverted back to zero after inserting a new element. Seem like it should be simple. What am I missing?

0 项奖励
1 条消息(共 7 条)
6,999 次查看
解答
已被主题作者 RHutchings 接受

Because the initialize array is inside the for loop, it's creating a new array of 0's every loop, getting rid of your old data.

 

You can move the initialize array outside of the loop and use a shift register to update the array using "Replace Array Subset", instead of "Insert into Array".

 

Alternatively, you could use auto-indexing to dynamically create the array without needing to initialize it first. This method is much simpler.

 

Build an Array

2 条消息(共 7 条)
6,972 次查看

So what youre doing is initializing an array of N,5 in this case, to zero.  This creates an array of 5 elements that you set to 0. You then proceed to insert the iteration + 1 at index iteration + 1.  So after the for loop completes you have an element of 5 zeros and then you insert the final iteration (4) + 1.  This gives you an array of 0,0,0,0,0,5.  Exactly as it should.

 

Im assuming you want your final array to be 1,2,3,4,5? is that correct then you should initialized outside the array and then you need to place shift registers on the for loop and have that array go into and out of the replace array.Array.PNG



-Matt
3 条消息(共 7 条)
6,971 次查看

If you want to make array of [1 2 3 4 5], just open Labview basics course and find what is "Autoindexing" of terminals in a For loop. 

0 项奖励
4 条消息(共 7 条)
6,961 次查看

The autoindexing worked perfectly. Thanks you.

0 项奖励
5 条消息(共 7 条)
6,938 次查看

How is it possible to build array from 70 to 30 for example ? Thank you

0 项奖励
6 条消息(共 7 条)
3,424 次查看

@LilySamchuk wrote:

How is it possible to build array from 70 to 30 for example ? Thank you


Continued here.

0 项奖励
7 条消息(共 7 条)
3,405 次查看